Programming

Open a URL in the Default Browser in Your .NET Application

Virtually every application these days requires at least some connection to the internet. Letting the user click a link and open it in their browser is essential. This recipe shows you the 1 line method of doing so.
This is the absolute simplest way to launch a URL in a .NET application:
System.Diagnostics.Process.Start(”http://www.tech-recipes.com”);
Just put this code in [...]

31Dec2008 | siman | 0 comments | Continued

Pass Variables to a New Thread in C#

When you create a new thread in .net 1.1, you cannot pass any parameters to the ThreadStart delegate, which makes passing startup variables difficult. This recipe shows you an easy workaround.
Since the ThreadStart delegate doesn’t accept parameters, you need to set the parameters somewhere before you create the new thread. What we’ll do is create [...]

31Dec2008 | siman | 0 comments | Continued

Load an Icon from an Embedded Resource in .NET

When you are developing a Windows Forms application in .NET, it’s not immediately obvious how to programatically load an icon file embedded in your executable. This recipe shows you the 1 line solution.
Your icon file should be a regular windows icon file. Add it to your project, and in the properties for the icon make [...]

31Dec2008 | siman | 0 comments | Continued

Ruby on Rails: Reload Script/Console Without Restarting

When you are testing your rails application using script/console, you have to stop and start the console to test changes to your model objects. This recipe shows you the easy way to reload the console.
If you are using windows, you start the console by using this command: ruby scriptconsole
Linux:./script/console
Just use the following command whenever you [...]

31Dec2008 | siman | 0 comments | Continued

Subversion: See the Latest Repository Revision Number

The Subversion source control system has a simple and easy to use command-line syntax. This recipe shows you how to see what the latest revision number in the repository is.
The svn info command takes either local or url arguments. This will let you tell what the version on the repository is compared to the version [...]

26Dec2008 | siman | 0 comments | Continued

Make Wordpress Stop Replacing Double Dash with Em-dash

Wordpress by default replaces the double dash (–) with an em-dash character. If you are showing code or programming examples this will cause your visitors unnecessary confusion. This recipe shows the simple way to turn that behavior off.
This problem is occurring because Wordpress automatically runs a bunch of filters on your content before displaying it [...]

26Dec2008 | siman | 0 comments | Continued

Tag A Specific Version of Your Project In Subversion

When you finally finish version 0.9 of your beta Web 2.0 application, you’ll probably want to tag that version in your source control system. This recipe shows you how using Subversion.
Tagging versions in Subversion is done by using the svn copy command. The subversion copy won’t actually create a physical copy of your project, but [...]

26Dec2008 | siman | 0 comments | Continued

Configure Subversion Client to Ignore Certain Files

Subversion by default shows unversioned files and folders when running the svn status command. This recipe shows you how to ignore files you don’t want in source control.
In your subversion project directory, you will use the following command format:
svn propset svn:ignore file1 file2 directory1
For example:
svn propset svn:ignore bin obj *.exe
This command will ignore the bin [...]

26Dec2008 | siman | 0 comments | Continued