Archive for the Technology Category


The #1 programmer excuse for legitimately slacking off - “my code’s compiling”

The #1 programmer excuse for legitimately slacking off -

Generate NHibernate Mappings from your SQL Server or MySQL database

My favorite tool when working with NHibernate is MyGeneration. MyGeneration is a code generator and O/R mapping solution. It’s as simple as selecting the script to run, setting up your database connection string, and clicking run. It can instantly generate class files along with the required NHibernate mapping files. This can save a lot of time upfront when you need to quickly access your database.

Here is my step-by-step guide to getting NHibernate mappings and class files from your database:

1) Download and install the latest copy of MyGeneration from here.

2) Make sure you have the required connector for your database. Several databases are supported natively; however, others will require an additional download. See this page for more information and links to connectors to download. Note: My computer has Visual Studio 2005 and SQL Server 2005 installed, so the SQL Server connectors were already installed. However, I did need to install a connector for MySQL. Once installed, I also had to navigate to the installation folder to retrieve the binary connector file. It was called MySql.Data.dll. I simply copied this into the base MyGeneration folder and was ready to go!

3) Run MyGeneration. When prompted to set the Default Settings, set the connection to your database. For MySQL select MySQL2 from the driver list. Remember to test the connection to make sure it works before saving.

4) Find the template for NHibernate. On the left hand side of the screen is the Object Browser. Click the globe icon to open the Online Template Gallery. Expand the NHibernate section and choose a template. In my case, I picked one for NHibernate 1.2. Press the save icon to save it locally.

5) Expand the NHibernate folder in the Object Browser. Double click on a template to open it. Click the green start button to run. The pop up window will allow you to specify various options for the output. Typically, you are able to specify the namespace and assembly information, select a database using your connection information, and which tables/views to map. One mistake I made at fist was not selecting any tables. If you do not select any, it will still say the script ran successfully. When you are happy with your selections, choose OK to run the template. The code will be created in your output folder!

As you can see, once setup, code generation can quickly speed up the development process by eliminating the tedious tasks and letting developers focus on what is really important - the business logic!

How To: Use 1680×1050 resolution in Ubuntu on a LG 204WT monitor

Ubuntu LogoWhen I received my free copy of Windows Vista Ultimate, I left space on my hard drive to setup a dual boot using Ubuntu Linux. Everything worked great, my devices all work; however, I was limited to standard resolutions on my monitor! The issue? My monitor, a LG 204WT, is a wide screen, and the standard resolutions makes everything look stretched and terrible! Well, until the day that wide screen monitors are easily detected in Ubuntu, you can simply add the resolution yourself! Note: Remember to make a backup in case anything goes wrong!

Simple open up a terminal window and follow the steps:

1) Navigate to the folder:

cd /etc/X11

2) Now is the time to make a backup of the xorg.conf file!

sudo cp xorg.conf xorg.conf.backup

3) Open the configuration file:

sudo gedit xorg.conf

4) Search for the Monitor section and modify it to match the configuration below:

Section "Monitor"
     Identifier     "Generic Monitor"
     VendorName     "LG"
     ModelName      "LG L204WT"
     HorizSync       28.0 - 83.0
     VertRefresh     56.0 - 75.0
     Option         "DPMS"
EndSection

5) Search for the Screen section and modify it to match the configuration below. Note: The option’s information should all be on one line.

Section "Screen"
     Identifier     "Default Screen"
     Device         "x1800"
     Monitor        "Generic Monitor"
     DefaultDepth    24
     Option         "metamodes" "DFP-0: 1680x1050 +0+0" #; DFP-0: 1280x1024 +0+0;
                       DFP-0: 1024x768 +0+0; DFP-0: 832x624 +0+0; DFP-0: 800x600 +0+0;
                       DFP-0: 640x480 +0+0"
     SubSection     "Display"
          Depth       24
          Modes      "1680x1050" #"1600x1200" "1280x1024" "1024x768" "800x600" "640x480"
     EndSubSection
EndSection

6) Save and close the window. Now you will need to restart the environment. Press the key combination below, then login as usual:

Press Crtl+Alt+Backspace

7) Once logged back in, you can set the resolution by clicking on:

System->Preferences->Screen Resolution, then select 1680x1050!

Computer Mouse using a Dead Mouse!

In case you ever wondered, yes, you can create a computer mouse using a dead mouse. It may not be pretty, but it can be slightly cool to show off to your friends. Check out this site for more information and pictures.

Note the hilarious warning: “This project involves taxidermy, dremels, and sometimes graphic pictures of dead animals. While there are no guts in this tutorial, viewer discretion is still advised. If you are offended by this entire idea, please peruse the wallet contest or the laser cutter contest instead”.

Enjoy!

A real computer mouse!

Windows Vista: Force the ‘All Items’ view to all folders!

Windows VistaOnce the major annoyances of Vista is the way it changes the folder view based on the files inside of it. Add some pictures and suddenly your downloads folder turns into a picture template. Arg! Anyways, after some searching, I found a solution here.

Copy the text between the lines below into notepad & save as AllItemsView.reg file. (Or download this one).

Watch out for line wrap — [HKEY_CURRENT_USER\...\Shell] is all one line, there is a space between ‘Local’ and ‘Settings’.


Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags\AllFolders\Shell]
“FolderType”=”NotSpecified”


Merging the AllItemsView.reg file will set the ‘All Items’ template for any folders that don’t currently have a view saved with a different template.

You can clear all saved views by deleting the “HKCU\Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\Bags” key BEFORE merging the AllItemsView.reg file. (Using Start->Run->RegEdit).

If any folders open with a different template after clearing the ‘Bags’ key & merging the .reg file, they most likely have a template specified via their desktop.ini file.

Paint.NET

Paint.NET

I’ve been using Paint.NET for the last few months and, I think it’s about time to mention it here on the site.

I don’t need Photoshop or anything fancy to edit images. I just need more features then Paint has! Paint.NET does everything I need and on the plus side - it’s free! I use it to: resize images, save images to a different format, and to add some effects to images.

I’d encourage you to grab a copy to try out!

Javascript: Example switch statement using a range of values.

Here is a sample snippet which should give a good example of how to use a range of values inside of a javascript switch statement:

<script language="JavaScript" type="text/javascript">
<!--
	function GetText(value)
	{
		var result;

		switch (true)
		{
			case (value == 0):
				result = "Equals Zero.";
				break;

			case ((value >= 1) && (value <= 25)):
				result = "Between 1 and 25.";
				break;

			case ((value >= 26) && (value <= 50)):
				result = "Between 26 and 50.";
				break;

			case ((value >= 51) && (value <= 75)):
				result = "Between 51 and 75.";
				break;

			case ((value >= 76) && (value <= 100)):
				result = "Between 76 and 100.";
				break;

			default:
				result = "Not found in the range.";
				break;
		}

		return result;
	}

//-->
</script>

Legend of Zelda NES Map

After downloading the Legend of Zelda for the Wii’s Virtual Console, I found out that I don’t remember where I’m going, and I keep getting lost!

After some searching, I found a copy of the map that describes what is sold in the stores, the order of the dungeons, and other hidden items!

Check it out by clicking on the image below:

Legend of Zelda NES Map

So you modded your Wii and now you can’t connect to the internet…

Nintendo WiiWell, if you happen to be in this situation (or you just took out the internal battery to have a look), don’t stress. It can be fixed, although it will be a little tedious. After an extensive search using Google, I finally found a forum post that gave a solution. I’m showing the steps again in the hopes that it makes it easier for someone else to find this fix. I have also added some of my own comments after going through the process. The fix goes a little like this:

  1. Backup your game saves to your SD card. Backup your Miis to your controller. (Note: Don’t bother backing up any channels or virtual console games, you will need to download these again using the Shop channel).
  2. Reformat the Wiis internal memory (found on third page of the Wii options).
  3. Turn the Wii back on and go through initial setup to completion. You do not need to setup the internet yet.
  4. Turn the Wii off and remove the lithium battery panel along with the battery. It’s the silver screw on bottom side of the Wii.
  5. Turn the Wii back on (with the battery still removed) and again reformat internal memory
  6. When the Wii turns off after the reformat, unplug the power for ten minutes (with the battery still removed).
  7. Plug the Wii back in. Turn on the Wii and again go through the initial setup to completion (with the battery still removed).
  8. Enter your internet settings and run the internet connection test.
  9. Go to WiiConnect24 and make sure you have it set to ON (Standby is also turned ON).
  10. Make sure you accept the Internet User Agreement.
  11. Now start up the News channel. You should now get your news updates.
  12. Go to the Weather channel and go through the setup. You should now get your weather updates.
  13. Now, insert each of your Wii games to create the initial save game. Delete the initial save game, then copy the saved games from the SD card to your Wii. (Note: It wouldn’t let me copy the save games until I did this).
  14. Create a new Mii using the Mii channel, then copy your Miis from the controller to your Wii. Delete the new Mii when you are finished. (Note: This process seemed to screw up my Wii Sports save game. It forgot all the scores for my Miis).
  15. Finally, turn off the Wiis power. Reinstall the battery and battery panel (make sure battery faces correct way), and your done

I did this a week ago and it’s been working perfect ever since. The whole back up process is incredibly tedious on the Wii, something that could use some improvement, but regardless, I’m just glad its back to normal.

   Newer→