Programming FAQ: Page 82
-
How to script Visual Studio 2008 from Python?
Exerpt: I'd like to write Python scripts that drive Visual Studio 2008 and Visual C++ 2008. All the examples I've found so far use win32com.client.Dispatch. This works fine for Excel 200 …
Tags: python, visualstudio, visualstudio2008, visualc++
-
What are you doing to become a better developer?
Exerpt: These are the things which I do regularly: Read other people's code Read blogs Listen to podcasts Posting to my blog Read books (mostly technical) I'm curious if there's someth …
Tags: self improvement
-
How do I compile an ASP.NET website into a single .DLL?
Exerpt: I have finally finished my web site. I published it and I was surprised at the results. Although the App_Code compiled into a single .dll, every pages code behind compiled into it' …
Tags: visualstudio, compile, dll, web deployment project, asp.net
-
Validating posted form data in the ASP.NET MVC framework
Exerpt: I've been playing around with the ASP.NET MVC Framework and the one thing that's really confusing me is how I'm meant to do server side validation of posted form data. I presume I …
Tags: asp.net, asp.net mvc, mvc, validation
-
Best approach with dynamic classes using Python globals()
Exerpt: Hi! I'm working on a web application that will return a variable set of modules depending on user input. Each module is a Python class with a constructor that accepts a single para …
Tags: python, coding style, namespaces
-
What are the best resources on designing a new language?
Exerpt: I've been toying with the idea of building a new general purpose programming language lately, and I was wondering where to go for help. Does anyone have a favorite book? Tutorial …
Tags: design, compiler, language
-
What’s the difference between creating a UNIQUE index as “index” or as “constraint” in SQL Server?
Exerpt: When creating an index over a column that is going to be UNIQUE (but not the primary key of the table), SQL server let's me choose a few options: 1) I can choose for it to be a Co …
Tags: sqlserver, index, constraints, unique
-
Firebug for IE
Exerpt: Trying to fix JavaScript bugs is huge pain as is determining the styles applied to an element. Firebug makes these issues a lot easier when working on Firefox, but what do you do w …
Tags: web development, debugging, internet explorer, firebug
-
What’s the simplest way of adding one to a binary string in Perl?
Exerpt: I have a variable that contains a 4 byte, network-order IPv4 address (this was created using pack and the integer representation). I have another variable, also a 4 byte network-o …
Tags: perl, arithmetic, binary
-
How do I remove duplicate items from an array in Perl?
Exerpt: I have an array in Perl: @my_array = ("one","two","three","two","three") How do I remove the duplicates from the array?
Tags: perl, array, duplicates, unique
-
Operations on arbitrary value types
Exerpt: This article describes a way, in C#, to allow the addition of arbitrary value types which have a + operator defined for them. In essence it allows the following code: public T Add …
Tags: c, c++, cuda, gpgpu, valuetypes
-
Higher pay for advanced degrees?
Exerpt: Are advanced degrees such as Master's degrees or PhDs beneficial for software engineers? Should they be compensated for their advanced degree? There are plenty of programmers that …
Tags: career development, education
-
grep —exclude/—include syntax (do not grep through certain files)
Exerpt: I'm looking for the string "foo=" (without quotes) in text files in a directory tree. It's on a common Linux machine, I have bash shell: grep -ircl "foo=" * In the directories a …
Tags: unix, command line, grep, search, shell
-
How do you handle huge if-conditions?
Exerpt: It's something that's bugged me in every language I've used, I have an if statement but the conditional part has so many checks that I have to split it over multiple lines, use a n …
Tags: language agnostic, if
-
.Net CAD vector graphics library
Exerpt: What is a good .Net vector graphics library that can be used for CAD like applications, and has a reasonable set of features specific for this type of applications, like computatio …
Tags: .net, c#, cad, vector graphics
-
Any reason not to start using the HTML 5 doctype?
Exerpt: <!DOCTYPE html> It is supposed to be backwards compatible with HTML4 and XHTML. John Resig posted about some of the benefits. As long as we don't use any of the new and …
Tags: html, doctype, html5
-
Intranet Vs Internet Web application considerations
Exerpt: What are the differences in considerations in respect to designing or developing an Intranet and an Internet application ?
Tags: web, web development, intranet
-
Dependency Injection/Inversion of Control
Exerpt: I am about to dip my toe into DI/IoC for the first time with part of an app we have in production. I've spent the last month or so researching DI/IoC and will most likely use the C …
Tags: ioc, dependency injection, inversion of control
-
How to remove old versions of Eclipse plugins?
Exerpt: After update, old Eclipse plugins remain in "plugins" folder (there are also leftovers in "features" folder). Is there a way to remove those automatically?
Tags: eclipse, plugins
-
How do I retrieve my MySQL username and password?
Exerpt: I lost my MySQL username and password. How do I retrieve it?
Tags: mysql
-
Ruby on Rails and jeditable (jquery)
Exerpt: Hi there, Has anyone gotten the jquery plugin jeditable to run properly in a Rails applications. If so, could you share some hints on how to set it up? I'm having some trouble wit …
Tags: jquery, jeditable, ruby, rails, rubyonrails
-
Why can’t I call toString() on a Java primitive?
Exerpt: I want to convert a primitive to a string, and I tried: myInt.toString(); This fails with the error: int cannot be dereferenced Now, I get that primitives are not reference t …
Tags: java, primitive, autoboxing
-
Hibernate: hbm2ddl.auto=update in production?
Exerpt: Is it okay to run Hibernate applications configured with hbm2ddl.auto=update to update the database schema in a production environment?
Tags: java, hibernate
-
what’s in your .bashrc ?
Exerpt: .bashrc modifications are like nesting for developers. All I have right now is a few aliases and some PATH modifications. What's in yours?
Tags: linux, bash, profile, settings, configuration
-
Is it okay to update a Java web application by replacing just single class files?
Exerpt: Sometimes, when we're doing small changes to our web apps, e.g. bug fixes, we don't build a whole new WAR-file each time, but merely replace just the affected class files in the ex …
Tags: java, web applications
-
SIMPLE Bug Tracking Suggestions?
Exerpt: Any suggestions for good, solid, bug tracking solutions that let me (and company members) document bugs in 1-or-2-click steps? Basically I grew tired of all the overhead Mantis bri …
Tags: software, bugs
-
What GNU tools for refactoring are there?
Exerpt: How to refactor c source code that compiles with gcc, preferably a tool that can be used from the command line?
Tags: refactoring, gnu, gcc, tools, software tools
-
Why can’t I have abstract static methods in c#?
Exerpt: I've been working with providers a fair bit lately and I came across an interesting situation where I wanted to have an abstract class that had an abstract static method. I read a …
Tags: c#, .net
-
Pros and cons of using md5 hash of URI as the primary key in a database
Exerpt: I'm building a database that will store information on a range of objects (such as scientific papers, specimens, DNA sequences, etc.) that all have a presence online and can be ide …
Tags: md5, uri, guid, database, primary key
-
Paging SQL Server 2005 Results
Exerpt: How do I page results in SQL Server 2005? I SQL Server 2000, there was no reliable way todo this but I'm now wondering if SQL Server 2005 has any built in method. What I mean …
Tags: sql, paging
-
Free Python hosting
Exerpt: Is there a free working python host on which I can live test a django app? Google app engine is not an option.
Tags: python, django, hosting
-
Perl: while ($key = each %hash) doesn’t stop at key = 0
Exerpt: I don't need this, obviously; I'm just curious about what's going on here. Am I missing something simple? Can I rely on this behaviour in all versions of Perl?) Perl v5.8.8: %h = …
Tags: perl, while, each, hash
-
What’s the BEST way to remove the time portion of a datetime value (SQL Server)
Exerpt: Here's what I use: SELECT CAST(FLOOR(CAST(getdate() as FLOAT)) as DATETIME) I'm thinking there may be a better/more elegant way. Requirements: - it has to be as fast as …
Tags: sqlserver
-
How does Google Reader get every item in an RSS feed?
Exerpt: Slashdot's RSS feed is http://rss.slashdot.org/Slashdot/slashdot. If I download the XML file directly, I only get a few of the posts from today. However, if I subscribe to the feed …
Tags: rss, google reader, api
-
Calling Bash Commands From Ruby
Exerpt: How do I call console/bash commands from inside of a Ruby Program? Also, how do I get output from these commands back into my program?
Tags: ruby, bash, console, interop
-
Passing a string to an already running instance of an application
Exerpt: I have an application that detects if there is another instance of the app running and exits if one is found. This part seems to work reliably. My app takes a command-line argument …
Tags: delphi, winapi
-
What are the preferred versions of Vim and Emacs on OSX?
Exerpt: For those of us that like to use the graphical version of Vim or Emacs, instead of the console version, which version do you recommend? For Vim, there's Mac OSX Vim, MacVim, Vim …
Tags: mac, osx, emacs, vim, editors
-
Using set.insert( key ) as a conditional?
Exerpt: I am trying to use set.insert (key) as a conditional, where if the key is inserted correctly (meaning that the key does NOT already exsist in the set ) then it should go on and per …
Tags: c++, sets, conditional, insert
-
Modify Address Bar URL in AJAX App to Match Current State
Exerpt: I'm writing an AJAX app, but as the user moves through the app, I'd like the URL in the address bar to update despite the lack of page reloads. Basically, I'd like for them to be a …
Tags: ajax, rest, url, address bar
-
C++ IDE for Macs
Exerpt: I teach a C++ course using Visual Studio. One of my students has a Mac, and was looking for an IDE to use on his machine. What would be good to recommend?
Tags: c++, mac, ide
-
What are the advantages of using SVN over CVS?
Exerpt: My company currently uses CVS as our defacto standard for source control. I've heard many people say SVN is better, and I know that it's newer, but other than that am not sure of …
Tags: svn, version control, cvs
-
How to deal with time storage in SQL
Exerpt: I have a web application that I'm writing (C#, MSSQL) and I need to store the timestamp when a record is stored in the system. Normally, I would just do this with SQL and the DATE …
Tags: sql, time, c#
-
Windows Help files - what are the options?
Exerpt: Back in the old days, Help was not trivial but possible: generate some funky .rtf file with Special Tags, run it through a compiler, and you got a WinHelp file (.hlp) that actually …
Tags: windows, language agnostic, chm, rant, htmlhelp
-
Determine Process Info Programmatically in Darwin/OSX
Exerpt: I have a class with the following member functions: /// caller pid virtual pid_t Pid() const = 0; /// physical memory size in KB virtual uint64_t Size() const = 0; /// resid …
Tags: c++, c, macosx, darwin, operating system
-
IP to Country?
Exerpt: Does anyone know of a simple way to retrieve the country for a given IP Address? Preferably in ISO_3166-1 format?
Tags: ip, lookup, country, iso 3166 1, iso 3166 1 alpha 2
-
Best cubicle toys for programming
Exerpt: I need some employee/co-worker Christmas gift ideas. Do you have any good cubicle toys that help you to do any of: think about programming problems solve programming problems by …
Tags: opinion, physical computing, toys, subjective
-
How much of the Web build process do you/should you automate?
Exerpt: And what is your system of choice? Off the top of my head I would say that for a real one step web 'build' the following steps would have take place: Take a source snapshot …
Tags: web development, build process, ant, phing, joeltest
-
Accessing HTTP Headers in Javascript?
Exerpt: How do I access the HTTP response headers via JavaScript? Related to this question, which was modified to ask about specifically accessing browser information.
Tags: javascript, http, http headers
-
Check for changes to a SQL table?
Exerpt: How can I monitor a MSSQL database for changes to a table without using triggers or modifying the structure of the database in any way? My preferred programming environment is .Ne …
Tags: sqlserver, datatable
-
Is there a faster alternative to Google Analytics?
Exerpt: I like to keep my websites extremely light and fast, but of course I need some kind of user tracking and analytics. It seems like Google Analytics always takes significant enough …
Tags: analytics, google analytics, performance
-
How do you store third party libraries in your source control?
Exerpt: How do you store third party libraries that you use in your project in your source control? When would you store binaries in your source control? When would you store the code in …
Tags: source control
-
Multipart forms from C# client
Exerpt: I am trying to fill a form in a php application from a C# client (Outlook addin). I used Fiddler to see the original request from within the php application and the form is transmi …
Tags: c#, http, multipartform data
-
Getting started with F#
Exerpt: What's a good way to get into F# programming? What's a good "Hello world" example and what simple examples can show me why I want to use it over C#. Also what tools do I need? I …
Tags: f#
-
Large Inner classes and private variables
Exerpt: One thing I've run into a few times is a service class (like a JBoss service) that has gotten overly large due to helper inner classes. I've yet to find a good way to break the cla …
Tags: java, class design, jboss
-
Why should files end with a newline?
Exerpt: I assume everyone here is familiar with the adage that all text files should end with a newline. I've known of this "rule" for years but I've always wondered — why?
Tags: history, textfiles, general, files, newline
-
Should you collect the young generation first in a full garbage collection?
Exerpt: I'm writing a program that contains a generational garbage collector. There are just two generations. What I wonder is: When doing a full collection, do I gain anything (performanc …
Tags: generational, garbage collection
-
POCO vs DTO
Exerpt: POCO = Plain Old CLR (or better: Class) Object DTO = Data Transfer Object In this post there is a difference, but frankly most of the blogs I read describe POCO in the way DTO is …
Tags: .net, c#, poco, dto
-
Generating unique codes in PHP/MySQL?
Exerpt: I'm working with a client that needs to generate millions of the alphanumeric codes used in magazine scratch-off cards, bottlecap prizes, and so on. They have to be short enough to …
Tags: serialnumber, generators, random number generator, php, mysql
-
What are best practices for self-updating PHP+MySQL applications?
Exerpt: It is pretty standard practice now for desktop applications to be self-updating. On the Mac, every non-Apple program that uses Sparkle in my book is an instant win. For Windows dev …
Tags: php, update, upgrade, mysql, security
-
Query that returns list of all Stored Procedures in an MS SQL database
Exerpt: Is there a query that returns the names of all the stored procedures in an MS SQL database (excluding "System Stored Procedures" would be a nice touch)?
Tags: sqlserver, sql, stored procedures
-
What to do if a senior member of the team keeps breaking things?
Exerpt: Theoretically, if you were in a position where a senior member of the team had the authority to make bad decisions, which affected the business in a bad way, and kept implementing …
Tags: boss, breaking, subjective
-
Interface Contract, Class Object?
Exerpt: Is contract to interface as object is to class? What is the need to differentiate identical things like this, from the code to the executing code? I sort of get the idea behind n …
Tags: interface, contract, class, object
-
Why are VB.net programmers looked down upon?
Exerpt: I'm mainly a flash and PHP web developer. I have been trying to learn some new languages and I thought it would be good to use VB.net for my introduction to .NET. However both onl …
Tags: .net, vb.net, subjective, newbie
-
How to plan test time
Exerpt: Say suppose 10 developers have taken 6 months to develop some application. As a project manager how much time should I spare in my plans for testing? 6 months of effort includes u …
Tags: testing, project planning, project management
-
Torn Between learning PHP [insert framework here] and Ruby on Rails
Exerpt: Here's my situation: I'm an ASP.NET Developer first and foremost. That's not going to change anytime soon. I have built my small business on it. With that being said, I'm lookin …
Tags: php, ruby, rails, rubyonrails, web development
-
django,fastcgi: how to manage a long running process?
Exerpt: I have inherited a django+fastcgi application which needs to be modified to perform a lengthy computation (up to half an hour or more). What I want to do is run the computation in …
Tags: python, django, fastcgi
-
Knowing C++, how long does it take to learn Java?
Exerpt: I am a competent C++ developer. I understand and use polymorphism, templates, the STL, and I have a solid grasp of how streams work. For all practical purposes, I've done no Java …
Tags: c++, java, learning, subjective
-
Is implementing java.io.Serializable even in simple POJO Java classes a best practice?
Exerpt: In general, is it a best practice to have simple POJO Java classes implement java.io.Serializable?
Tags: java, serialization, best practices
-
How did you get involved with your open source community?
Exerpt: It seems that the normal progression to join projects is to contribute for a while, earn the trust, then get accepted as a member of the community (i.e. having commit access). Now …
Tags: subjective, open source
-
Best practices for source control and bug fixes
Exerpt: If we need to issue a bug patch that does not include current development that has been committed, or any changes from their current version, what should be done to make the proce …
Tags: source control, subversion, visualstudio, patches
-
What idiom (if any) do you prefer for naming the “this” parameter to extension methods in C#, and why?
Exerpt: The first parameter to a C# extension method is the instance that the extension method was called on. I have adopted an idiom, without seeing it elsewhere, of calling that variable …
Tags: c#, c#3.0, extension methods, idioms, .net
-
How to change a span to look like a pre with CSS?
Exerpt: Is it possible to to change a <span> tag (or <div>) to preformat its contents like a <pre> tag would using only CSS?
Tags: html, web development, css
-
What warnings would you like a “warnins” pragma to throw?
Exerpt: Recently on the Perl5 Porters list a spelling error in a doc patch made me laugh: use warnins; I now feel compelled to write a "warnins" pragma which such sage advice as Yer u …
Tags: perl, humor
-
Literate programming
Exerpt: Literate programming is a way of developing software where documentation comes first, then the coding. One writes the documentation of a code snippet, and then writes the implement …
Tags: literate programming, .net, ide, msword, tools
-
Is there a Perl equivalent to Python’s `if __name__ == ‘__main__’`?
Exerpt: Is there a way to determine if the current file is the one being executed in Perl source? In Python we do this with the following construct: if __name__ == '__main__': # This …
Tags: perl, python, executable
-
Generics in legacy code
Exerpt: We've got a fairly large amount of code that just made the jump to Java 5. We've been using generics in those components targeted at being released in the Java 5 version, but the r …
Tags: java, legacy code, generics, migration
-
Is the Win32 Registry ‘thread safe’?
Exerpt: If I have two processes accessing a given registry key (off of HKLM), is it a good idea to wrap the logic in a Mutex?
Tags: win32, c#, multithreading
-
Dealing with some grey code style issues
Exerpt: We have an intermediate developer who is really good at what he does, but there is one rough edge to this diamond. He's really insistent that every method have only one entry and o …
Tags: people skills, people, coding standards
-
How do I code and compile an Amiga application?
Exerpt: I would like to program an application for the Amiga, just for fun! Please could someone post a step by step howto based on the following? Exactly what programming tools I shoul …
Tags: amiga, hello world, fun, nostalgia
-
How Python web frameworks, WSGI and CGI fit together
Exerpt: Hello, I have a Bluehost account where I can run Python scripts as CGI. I guess it's the simplest CGI because to run I have to define the following in .htaccess: Options +ExecCGI …
Tags: python, wsgi, apache, cgi, web development
-
What is meant by ‘first class object’?
Exerpt: In a recent question, I received suggestions to talk on, amongst other things, the aspect of JavaScript where functions are 'first class' objects. What does the 'first class' mean …
Tags: javascript, programming
-
Why is C# List<> not thread-safe?
Exerpt: from this site: http://crfdesign.net/programming/top-10-differences-between-java-and-c Unfortunately, List<> is not thread-safe (C#’s ArrayList and Java’s Vector are th …
Tags: thread safety, generics, .net
-
Best way to turn an integer into a month name in c#?
Exerpt: Is there a best way to turn an integer into its month name in .net? Obviously I can spin up a datetime to string it and parse the month name out of there. That just seems like a …
Tags: .net, dates, parsing
-
Web development for a Computer Scientist
Exerpt: I have BS in Computer Science, and thus have experience developing software that runs at the command line or with a basic GUI. However, I have no experience making real, functiona …
Tags: web development, process, rubyonrails, best practices, learning
-
C# Generics: Can I constrain to a set of classes that don’t implement an interface?
Exerpt: I have 3 classes that are essentially the same but don't implement an interface because they all come from different web services. e.g. Service1.Object1 Service2.Object1 Servic …
Tags: c#, generics, .net
-
Should developers have administrator permissions on their PC
Exerpt: Should developers have administrator permissions on their PC or is giving them power user access sufficient? Some comments: If they want to try out some new application that wo …
Tags: subjective, development environment
-
HTML Links and Usability
Exerpt: Should links on a web page ALWAYS be underlined? I do not believe this should be a hard and fast RULE! I wrote a comment on my blog awhile back about this after another developer …
Tags: html, usability, css, design, subjective
-
data structure used to implement UNDO and REDO option
Exerpt: I want to implement UNDO and REDO option(as we see in MS word etc). Can you suggest me a data structure for it, and how can i implement it.?
Tags: data structures, patterns
-
What is the right info to cache? What’s a good page load time?
Exerpt: I'm in the process of developing a social network site. And been thinking of scalability from day one of the project, I've fine tuned the site and queries to the best of my abilit …
Tags: cache, asp.net mvc, socialnetworking
-
Python: Do Python Lists keep a count for len() or does it count for each call?
Exerpt: If I keep calling len() on a very long list, am I wasting time, or does it keep an int count in the background?
Tags: python