Helpful Posts For Developers

Some Of The Best Answers From Latest Asked Questions

8

answers

JavaScript editor within Eclipse

I'm looking for the best JavaScript editor available as an Eclipse plugin. I've been using Spket which is good. But, is there more better one?..

22

answers

Abstraction VS Information Hiding VS Encapsulation

Can you tell me what is the difference between abstraction and information hiding in software development? I am confused. Abstraction hides detail implementation and information hiding abstracts whol..

15

answers

Initialize class fields in constructor or at declaration?

I've been programming in C# and Java recently and I am curious where the best place is to initialize my class fields. Should I do it at declaration?: public class Dice { private int topFace = 1;..

7

answers

SQL Server: Examples of PIVOTing String data

Trying to find some simple SQL Server PIVOT examples. Most of the examples that I have found involve counting or summing up numbers. I just want to pivot some string data. For example, I have a que..

45

answers

C++ IDE for Linux?

I want to expand my programming horizons to Linux. A good, dependable basic toolset is important, and what is more basic than an IDE? I could find these SO topics: Lightweight IDE for linux and Wha..

9

answers

Algorithm to compare two images

Given two different image files (in whatever format I choose), I need to write a program to predict the chance if one being the illegal copy of another. The author of the copy may do stuff like rotati..

10

answers

What does 'IISReset' do?

On IIS 6, what does an IIS reset do? Please compare to recycling an app pool and stopping and starting an ASP.NET web site. If you replace a DLL or edit/replace the web.config on an ASP.NET web sit..

8

answers

How Best to Compare Two Collections in Java and Act on Them?

I have two collections of the same object, Collection<Foo> oldSet and Collection<Foo> newSet. The required logic is as follow: if foo is in(*) oldSet but not newSet, call doRemove(foo) ..

4

answers

Free ASP.Net and/or CSS Themes

Where can I get some decent looking free ASP.Net or CSS themes?..

28

answers

Algorithm to find Largest prime factor of a number

What is the best approach to calculating the largest prime factor of a number? I'm thinking the most efficient would be the following: Find lowest prime number that divides cleanly Check if result ..

17

answers

What is the difference between procedural programming and functional programming?

I've read the Wikipedia articles for both procedural programming and functional programming, but I'm still slightly confused. Could someone boil it down to the core?..

31

answers

When do you use the "this" keyword?

I was curious about how other people use the this keyword. I tend to use it in constructors, but I may also use it throughout the class in other methods. Some examples: In a constructor: public Ligh..

13

answers

What is the best way to prevent session hijacking?

Specifically this is regarding when using a client session cookie to identify a session on the server. Is the best answer to use SSL/HTTPS encryption for the entire web site, and you have the best gu..

53

answers

Language Books/Tutorials for popular languages

It wasn't that long ago that I was a beginning coder, trying to find good books/tutorials on languages I wanted to learn. Even still, there are times I need to pick up a language relatively quickly f..

44

answers

Calculate distance between two latitude-longitude points? (Haversine formula)

How do I calculate the distance between two points specified by latitude and longitude? For clarification, I'd like the distance in kilometers; the points use the WGS84 system and I'd like to underst..

12

answers

What's the difference between a temp table and table variable in SQL Server?

In SQL Server 2005, we can create temp tables one of two ways: declare @tmp table (Col1 int, Col2 int); or create table #tmp (Col1 int, Col2 int); What are the differences between these two? I ..

5

answers

How can I discover the "path" of an embedded resource?

I am storing a PNG as an embedded resource in an assembly. From within the same assembly I have some code like this: Bitmap image = new Bitmap(typeof(MyClass), "Resources.file.png"); The file, nam..

27

answers

Getting parts of a URL (Regex)

Given the URL (single line): http://test.example.com/dir/subdir/file.html How can I extract the following parts using regular expressions: The Subdomain (test) The Domain (example.com) The path wit..

2

answers

How can I add (simple) tracing in C#?

I want to introduce some tracing to a C# application I am writing. Sadly, I can never really remember how it works and would like a tutorial with reference qualities to check up on every now and then...

11

answers

What issues should be considered when overriding equals and hashCode in Java?

What issues / pitfalls must be considered when overriding equals and hashCode?..

48

answers

Detecting an undefined object property

What's the best way of checking if an object property in JavaScript is undefined?..

7

answers

How to convert std::string to LPCWSTR in C++ (Unicode)

I'm looking for a method, or a code snippet for converting std::string to LPCWSTR..

13

answers

Comparing Arrays of Objects in JavaScript

I want to compare 2 arrays of objects in JavaScript code. The objects have 8 total properties, but each object will not have a value for each, and the arrays are never going to be any larger than 8 i..

11

answers

How do I REALLY reset the Visual Studio window layout?

I had a plugin installed in Visual Studio 2008, and it created some extra dockable windows. I have uninstalled it, and I can't get rid of the windows it created - I close them, but they always come b..

17

answers

Getting all types that implement an interface

Using reflection, how can I get all types that implement an interface with C# 3.0/.NET 3.5 with the least code, and minimizing iterations? This is what I want to re-write: foreach (Type t in this.Ge..

11

answers

What is MVC and what are the advantages of it?

I found What are mvp and mvc and what is the difference but it didn't really answer this question. I've recently started using MVC because it's part of the framework that myself and my work-partner a..

6

answers

How to set encoding in .getJSON jQuery

In my web app, I submit some form fields with jQuery's $.getJSON() method. I am having some problems with the encoding. The character-set of my app is charset=ISO-8859-1, but I think these fields are ..

18

answers

How can I pass arguments to a batch file?

I need to pass an ID and a password to a batch file at the time of running rather than hardcoding them into the file. Here's what the command line looks like: test.cmd admin [email protected] > test-log.t..

10

answers

How can I play sound in Java?

I want to be able to play sound files in my program. Where should I look?..

9

answers

Filtering collections in C#

I am looking for a very fast way to filter down a collection in C#. I am currently using generic List<object> collections, but am open to using other structures if they perform better. Current..

10

answers

What is the best way to connect and use a sqlite database from C#

I've done this before in C++ by including sqlite.h but is there a similarly easy way in C#?..

17

answers

How can I measure the similarity between two images?

I would like to compare a screenshot of one application (could be a Web page) with a previously taken screenshot to determine whether the application is displaying itself correctly. I don't want an ex..

26

answers

Insert into ... values ( SELECT ... FROM ... )

I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible for many database engines, I always seem to struggle to remember the correct syntax for the SQ..

43

answers

Best programming based games

Back when I was at school, I remember tinkering with a Mac game where you programmed little robots in a sort of pseudo-assembler language which could then battle each other. They could move themselves..

11

answers

Copy/duplicate database without using mysqldump

Without local access to the server, is there any way to duplicate/clone a MySQL db (with content and without content) into another without using mysqldump? I am currently using MySQL 4.0...

16

answers

Delete all but the most recent X files in bash

Is there a simple way, in a pretty standard UNIX environment with bash, to run a command to delete all but the most recent X files from a directory? To give a bit more of a concrete example, imagine ..

7

answers

What is the best free memory leak detector for a C/C++ program and its plug-in DLLs?

I have a .exe and many plug-in .dll modules that the .exe loads. (I have source for both.) A cross-platform (with source) solution would be ideal, but the platform can be narrowed to WinXP and Visual ..

13

answers

Python module for converting PDF to text

Is there any python module to convert PDF files into text? I tried one piece of code found in Activestate which uses pypdf but the text generated had no space between and was of no use. ..

16

answers

Get OS-level system information

I'm currently building a Java app that could end up being run on many different platforms, but primarily variants of Solaris, Linux and Windows. Has anyone been able to successfully extract informati..

13

answers

How do I use itertools.groupby()?

I haven't been able to find an understandable explanation of how to actually use Python's itertools.groupby() function. What I'm trying to do is this: Take a list - in this case, the children of an ..

12

answers

How to create a new object instance from a Type

One may not always know the Type of an object at compile-time, but may need to create an instance of the Type. How do you get a new object instance from a Type?..

26

answers

What is the difference between an int and an Integer in Java and C#?

I was reading More Joel on Software when I came across Joel Spolsky saying something about a particular type of programmer knowing the difference between an int and an Integer in Java/C# (Object-Orien..

12

answers

The definitive guide to form-based website authentication

Form-based authentication for websites We believe that Stack Overflow should not just be a resource for very specific technical questions, but also for general guidelines on how to solve variati..

24

answers

How do you make sure email you send programmatically is not automatically marked as spam?

This is a tricky one and I've always relied on techniques, such as permission-based emails (i.e. only sending to people you have permission to send to) and not using blatantly spamish terminology. Of..

36

answers

Generate list of all possible permutations of a string

How would I go about generating a list of all possible permutations of a string between x and y characters in length, containing a variable list of characters. Any language would work, but it should ..

19

answers

How do you sort a dictionary by value?

I often have to sort a dictionary, consisting of keys & values, by value. For example, I have a hash of words and respective frequencies, that I want to order by frequency. There is a SortedList ..

11

answers

error_log per Virtual Host?

On one Linux Server running Apache and PHP 5, we have multiple Virtual Hosts with separate log files. We cannot seem to separate the php error_log between virtual hosts. Overriding this setting in th..

29

answers

Versioning SQL Server database

I want to get my databases under version control. Does anyone have any advice or recommended articles to get me started? I'll always want to have at least some data in there (as alumb mentions: user..

10

answers

Embedding Windows Media Player for all browsers

Edit: This question was written in 2008, which was like 3 internet ages ago. If this question is still relevant to your environment, please accept my condolences. Everyone else should convert into a f..

26

answers

Multiple submit buttons in an HTML form

Let's say you create a wizard in an HTML form. One button goes back, and one goes forward. Since the back button appears first in the markup when you press Enter, it will use that button to submit the..

13

answers

Difference between Math.Floor() and Math.Truncate()

What is the difference between Math.Floor() and Math.Truncate() in .NET?..

25

answers

Determine a user's timezone

Is there a standard way for a web server to be able to determine a user's timezone within a web page? Perhaps from an HTTP header or part of the user-agent string?..

39

answers

Calculate relative time in C#

Given a specific DateTime value, how do I display relative time, like: 2 hours ago 3 days ago a month ago ..

64

answers

How do I calculate someone's age based on a DateTime type birthday?

Given a DateTime representing a person's birthday, how do I calculate their age in years?..

38

answers

Learning to write a compiler

Preferred languages: C/C++, Java, and Ruby. I am looking for some helpful books/tutorials on how to write your own compiler simply for educational purposes. I am most familiar with C/C++, Java, and R..

97

answers

What good technology podcasts are out there?

Yes, Podcasts, those nice little Audiobooks I can listen to on the way to work. With the current amount of Podcasts, it's like searching a needle in a haystack, except that the haystack happens to be ..

8

answers

How do you express binary literals in Python?

How do you express an integer as a binary number with Python literals? I was easily able to find the answer for hex: >>> 0x12AF 4783 >>> 0x100 256 and octal: >>> 01267 ..

6

answers

Make XAMPP / Apache serve file outside of htdocs folder

Is it possible to configure xampp to serve up a file outside of the htdocs directory? For instance, say I have a file located as follows: C:\projects\transitCalculator\trunk\TransitCalculator.php a..

12

answers

How to check for file lock?

Is there any way to check whether a file is locked without using a try/catch block? Right now, the only way I know of is to just open the file and catch any System.IO.IOException...

15

answers

How big can a MySQL database get before performance starts to degrade

At what point does a MySQL database start to lose performance? Does physical database size matter? Do number of records matter? Is any performance degradation linear or exponential? I have what I ..

8

answers

How does database indexing work?

Given that indexing is so important as your data set increases in size, can someone explain how indexing works at a database-agnostic level? For information on queries to index a field, check out How..

17

answers

Adding a Method to an Existing Object Instance

I've read that it is possible to add a method to an existing object (i.e., not in the class definition) in Python. I understand that it's not always good to do so. But how might one do this?..

5

answers

String literals and escape characters in postgresql

Attempting to insert an escape character into a table results in a warning. For example: create table EscapeTest (text varchar(50)); insert into EscapeTest (text) values ('This is the first part \..

30

answers

How do you debug PHP scripts?

How do you debug PHP scripts? I am aware of basic debugging such as using the Error Reporting. The breakpoint debugging in PHPEclipse is also quite useful. What is the best (in terms of fast and eas..

14

answers

Are PHP Variables passed by value or by reference?

Are PHP variables passed by value or by reference?..

30

answers

Why is Git better than Subversion?

I've been using Subversion for a few years and after using SourceSafe, I just love Subversion. Combined with TortoiseSVN, I can't really imagine how it could be any better. Yet there's a growing n..

30

answers

.NET obfuscation tools/strategy

My product has several components: ASP.NET, Windows Forms App and Windows Service. 95% or so of the code is written in VB.NET. For Intellectual Property reasons, I need to obfuscate the code, and unt..

14

answers

Auto Generate Database Diagram MySQL

I'm tired of opening Dia and creating a database diagram at the beginning of every project. Is there a tool out there that will let me select specific tables and then create a database diagram for me ..

7

answers

Datatable vs Dataset

I currently use a DataTable to get results from a database which I can use in my code. However, many example on the web show using a DataSet instead and accessing the table(s) through the collections..

20

answers

How to call shell commands from Ruby

How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?..

5

answers

Creating a custom JButton in Java

Is there a way to create a JButton with your own button graphic and not just with an image inside the button? If not, is there another way to create a custom JButton in java?..

7

answers

Convert HashBytes to VarChar

I want to get the MD5 Hash of a string value in SQL Server 2005. I do this with the following command: SELECT HashBytes('MD5', 'HelloWorld') However, this returns a VarBinary instead of a VarChar v..

24

answers

What are MVP and MVC and what is the difference?

When looking beyond the RAD (drag-drop and configure) way of building user interfaces that many tools encourage you are likely to come across three design patterns called Model-View-Controller, Model-..

10

answers

How do I create a branch?

How do I create a branch in SVN?..

9

answers

What do the result codes in SVN mean?

What do the result codes in SVN mean? I need a quick reference...

26

answers

Python: What OS am I running on?

What do I need to look at to see whether I'm on Windows or Unix, etc?..

214

answers

What is the single most influential book every programmer should read?

If you could go back in time and tell yourself to read a specific book at the beginning of your career as a developer, which book would it be? I expect this list to be varied and to cover a wide rang..

12

answers

Create a directly-executable cross-platform GUI app using Python

Python works on multiple platforms and can be used for desktop and web applications, thus I conclude that there is some way to compile it into an executable for Mac, Windows and Linux. The problem be..

34

answers

Text Editor For Linux (Besides Vi)?

Let me preface this question by saying I use TextMate on Mac OSX for my text needs and I am in love with it. Anything comparable on the Linux platform? I'll mostly use it for coding python/ruby. Do..

40

answers

Options for HTML scraping?

I'm thinking of trying Beautiful Soup, a Python package for HTML scraping. Are there any other HTML scraping packages I should be looking at? Python is not a requirement, I'm actually interested in he..

13

answers

How do you format an unsigned long long int using printf?

#include <stdio.h> int main() { unsigned long long int num = 285212672; //FYI: fits in 29 bits int normalInt = 5; printf("My number is %d bytes wide and its value is %ul. A normal nu..

77

answers

Recommended add-ons/plugins for Microsoft Visual Studio

Can anyone recommend any good add-ons or plugins for Microsoft Visual Studio? Freebies are preferred, but if it is worth the cost then that's fine...

43

answers

How do I split a string so I can access item x?

Using SQL Server, how do I split a string so I can access item x? Take a string "Hello John Smith". How can I split the string by space and access the item at index 1 which should return "John"?..

85

answers

How do you disable browser Autocomplete on web form field / input tag?

How do you disable autocomplete in the major browsers for a specific input (or form field)?..

6

answers

MAC addresses in JavaScript

I know that we can get the MAC address of a user via IE (ActiveX objects). Is there a way to obtain a user's MAC address using JavaScript?..

6

answers

Capturing TAB key in text box

I would like to be able to use the Tab key within a text box to tab over four spaces. The way it is now, the Tab key jumps my cursor to the next input. Is there some JavaScript that will capture the ..

17

answers

How to set background color of HTML element using css properties in JavaScript

How can I set the background color of an HTML element using css in JavaScript?..

8

answers

Why can't I have abstract static methods in C#?

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 few posts on the to..

23

answers

Big O, how do you calculate/approximate it?

Most people with a degree in CS will certainly know what Big O stands for. It helps us to measure how well an algorithm scales. But I'm curious, how do you calculate or approximate the complexity of..

86

answers

Best ways to teach a beginner to program?

Original Question I am currently engaged in teaching my brother to program. He is a total beginner, but very smart. (And he actually wants to learn). I've noticed that some of our sessions have got..

14

answers

Calling a function of a module by using its name (a string)

What is the best way to go about calling a function given a string with the function's name in a Python program. For example, let's say that I have a module foo, and I have a string whose content is ..

38

answers

What is Inversion of Control?

Inversion of Control (IoC) can be quite confusing when it is first encountered. What is it? Which problem does it solve? When is it appropriate to use and when not? ..

9

answers

What's the safest way to iterate through the keys of a Perl hash?

If I have a Perl hash with a bunch of (key, value) pairs, what is the preferred method of iterating through all the keys? I have heard that using each may in some way have unintended side effects. S..

40

answers

What is recursion and when should I use it?

One of the topics that seems to come up regularly on mailing lists and online discussions is the merits (or lack thereof) of doing a Computer Science Degree. An argument that seems to come up time and..

16

answers

How can we generate getters and setters in Visual Studio?

By "generate", I mean auto-generation of the code necessary for a particular selected (set of) variable(s). But any more explicit explication or comment on good practice is welcome...

8

answers

SQL Case Expression Syntax?

What is the complete and correct syntax for the SQL Case expression?..

7

answers

How to easily consume a web service from PHP

Is there available any tool for PHP which can be used to generate code for consuming a web service based on its WSDL? Something comparable to clicking "Add Web Reference" in Visual Studio or the Eclip..

20

answers

How do I update Ruby Gems from behind a Proxy (ISA-NTLM)

The firewall I'm behind is running Microsoft ISA server in NTLM-only mode. Hash anyone have success getting their Ruby gems to install/update via Ruby SSPI gem or other method? ... or am I just being..

15

answers

Drop all tables whose names begin with a certain string

How can I drop all tables whose names begin with a given string? I think this can be done with some dynamic SQL and the INFORMATION_SCHEMA tables...

10

answers

How do I retrieve my MySQL username and password?

I lost my MySQL username and password. How do I retrieve it?..