Saturday, June 29, 2013

Vacation away from the computer

After a three month vacation from the programming lab, I'm back.
I got all your messages about the Twitter image downloader not working anymore.
I've checked the issue and it was because twitter stopped the support of the older Twitter API 1.0

I've updated the application and you can get the new version at:
https://twitterimagedownload.codeplex.com/

I'll create a post describing all the changes next week.

Happy downloading.

Saturday, April 13, 2013

Recursion in Microsoft Visual Studio


I've upgraded to Microsoft Visual Studio 2012 recently and am very happy with the new IDE.
I don't really want to get into the differences between the versions and the "whats new" list right now since you can easily find them with Google. http://www.lmgtfy.com/?q=what%27s+new+in+visual+studio+2012
I would however, like to talk about Recursion.

Recursion is basically a programming technique involving the use of a function that calls itself one or more times until a specified stopping condition is met at which time the rest of each repetition is processed from the last one called to the first.

A common "bug" when you don't set your stopping condition correctly. In such a case the recursion process keeps calling itself until it uses all the processes resources and crashes.
When this happens it is clearly a programming bug and not the IDE's fault.

I made a recursion error that I believe the new IDE should have stopped me from making.
Below is the snippet, can you see the problem ?

       private int recursionInt;

        public int RecursionInt
        {
            get { return RecursionInt; }
            set { recursionInt = value; }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int tmp = RecursionInt;
        }


The get function of the RecursionInt Property calls itself instead of recursionInt (I capitalized by mistake).
here is the screen capture of the exception
Property Recursion Exception

I would have thought the new Visual Studio IDE would detect such simple mistakes and stop the at design time just like they do when a function does not return any value.

What do you think ?

Just for fun, take a look at recursion by searching for it with Google.


Google is using the "Did you mean" feature, to illustrate the definition of recursion.
Check it out: https://www.google.com/search?q=recursion




Monday, March 25, 2013

Top ten software quotes

My top ten favorite software quotes


First a few Anonymous quotes

“ It’s not a bug – it’s an undocumented feature. ”

“ The best thing about a boolean is even if you are wrong, you are only off by a bit. ”

“ The best method for accelerating a computer is the one that boosts it by 9.8 m/s2. ”

“ In order to understand recursion, one must first understand recursion. ”

Michael Sinz
“ Programming is like sex. One mistake and you have to support it for the rest of your life. ”

John Johnson
“ First, solve the problem. Then, write the code. ”

 Andrew Hunt and David Thomas
“ It's not at all important to get it right the first time. It's vitally important to get it right the last time. ”

Fred Brooks
“ Adding manpower to a late software project makes it later ”

Tom Cargill
“ The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time. ”

Cory Doctorow
“ Engineers are all basically high-functioning autistics who have no idea how normal people do stuff. ”


John F. Woods
“ Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ”










Friday, March 22, 2013

16 Gigabit Transformer USB flash memory

I know that this post is going to re-validate me being a total nerd and geek but,
look what I received in the mail this week.

A 16 Gigabit Transformer USB flash memory drive.

COOL !!!


You can get it on eBay for about 9$ http://www.ebay.com/itm/Cute-16-GB-Black-Transformers-USB2-0-Flash-Memory-Stick-Pen-Drive-Free-Shipping-/390563912811

Wednesday, March 20, 2013

Install Windows 8 From USB Drive

I bravely decided that its time to upgrade to the new Windows 8.
For me, To actually go ahead with the upgrade, one of two things need to happen, a total system crash that cant recover or a period of two weeks of taking inventory of everything on my desktop and making a total backup of everything.

This time, I didn't wait for the crash.

Having almost everything set, after downloading the ISO from Microsoft, I wanted to burn the image to a DVD only to realize that the DVD decided to die and I threw the spare out months ago.

Since I'm not big on waiting to get a new one (I will Monday) I looked for a more immediate solution, Installing Windows 8 from a USB thumb drive.

There are two ways to get this accomplished as explained below:

Windows 7 USB / DVD download tool

The windows 7 USB / DVD download tool will copy the ISO file to your USB drive and make the USB drive bootable. It seems to be the most common and easiest way to create the bootable USB drive for Windows 7 or 8 installation.

Download the Windows 7 USB/DVD download tool from Microsoft here:  
http://images2.store.microsoft.com/prod/clustera/framework/w7udt/1.0/en-us/Windows7-USB-DVD-tool.exe

You can also read about it here:

Install the tool, its a fairly simple next, install, finish procedure.
Once installed, run the program. An icon should be placed on your desktop.
You will be asked to select the windows installation ISO file.

Next Choose the USB device option.

Select The correct USB  device and click on Begin copying.

The Tool will format your USB drive and set it up as a bootable device.

This was the simple Fool Proof way.

Create a bootable USB Drive

Some people prefer not to install unneeded programs or like creating things on their own.
lucky for them, its not that hard to create a bootable USB drive.

Connect your USB drive to the computer.
Open a command prompt with administrator rights.  
Start->All programs->Accessories->right click Command Prompt and select Run as administrator.

Now run "diskpart" from the command line to open the Microsoft DiskPart application.
Next type "list disk" into the application like in the above screen to obtain information about each disk in the computer. Note that for me Disk 1 was the Flash drive I inserted into the USB port.


We need to select the flash drive by entering "Select disk 1" and then remove any existing partition or volume formatting from the drive by clean the flash drive with the "clean" command.



Now we need to create a new partition on the drive we do this by entering "create partition primary"

Next we choose our new partition and activate it by entering "select partition 1" and then entering the "activate" command.

Now we can format the drive with a NTFS file system using "format fs=ntfs"
You need to be patient since this might take a few minutes.

Once we're done formatting our drive we can assign it a letter so it will be reachable on our system with the "assign" command.
At this point, were done with the DiskPart util and can close the util with the "exit" command.






Basically were done with the USB drive itself and now need to add the Windows 8 portion.
If you have Windows 8 on a CD, all you need to do is run "bootsect.exe /nt60 f:" from the boot directory in the CD, where f: of course stands for the USB drives assigned letter.
Since I had Windows 8 as an ISO file I had to unpack the directory first.


The final stage to get the USB drive ready is copy the contents of the CD to the USB drive or unpack the Windows 8 ISO file onto the Drive and restart your computer.

Don't forget to set your BIOS to support Boot from USB.

Good Luck !

Saturday, January 19, 2013

Creating a distribution package (.msi) for you VS project

Creating a distribution package (.msi) for you Visual Studio project

So you created a nice application in C# and want to share it with the world.
One way to do it is by creating a distribution package. By doing so Microsoft helps you by adding a few features to your setup process. I'll show you a few in the step by step.

First add a new installer project to your solution.
I choose Visual Studio Installer -> Setup Wizard which can be found in Setup and Deployment category

Visual Studio Installer
Visual Studio Installer

 Follow the wizard, its fairly simple.
Visual Studio Setup Wizard - Step 1


 Choose the project type you wish to create.

Visual Studio Setup Wizard - Step 2


Choose the project output you wish to use.
I usually select "Primary output from <Project>" as in the sample image below.
Visual Studio Setup Wizard - Step 3


The next page allows you to select files to add to the distribution.
The files can be a readme file, nfo file, images or whatever else you want to add.
Visual Studio Setup Wizard - Step 4
The final page is the confirmation.
At this point your done creating the simple package.

Adding Prerequisites to Installer

Sometimes, your project requires prerequisites to run correctly. The most common prerequisite is the .Net Framework itself. The Visual Studio Installer allows you to add the prerequisites with your distribution thus helping the user install the application correctly and your program run smother.

To add prerequisites, go to the setup project and open the properties.
Notice the Prerequisites button on the lower right.
 
Visual Studio Installer properties

After clicking the button, we can add the relevant items.
In my case I choose the .NET Framework 4 Client Profile so in the case that the user didn't download in advance, the .NET Framework, the Installation will help the user do so.
Notice that you can choose from where you want the component to be installed.
Either download from the vendors website (usually Microsoft) or from the location of the application. The same location means that the prerequisite will be bundled with your program making the install file larger.
I've never found much use for the third option.

Visual Studio Installer Prerequisites

Creating a shortcut to the application

One of the most important things an installer needs to do is add a shortcut to start up the application, we wouldn't want the user looking for the application all over the filesystem :-)

Go to the Install Projects' File System Editor. You can find it by selecting the Installer project from the solution explorer and notice the new icons at the top of the solution explorer. The file system editor is the second from the left.

Select the Application Folder
You should see the "Primary Output ..." in the window beside it.
Right click on the "Primary Output ..." and select the "Create Shortcut" option.
Now you can drag the new shortcut to the User's Desktop or the User's Program Menu.
I usually rename the shortcut as well.

Visual Studio Installer File System
The Installer has loads more features, if you find any good ones, leave a comment.

Monday, January 7, 2013

Adobe Creative Suite 2 free and legal


Lifehacker Posted today on their twitter feed that Adobe is offering free downloads of Creative Suite 2 (http://lifehacker.com/5973750).

 Basically it includes old versions of:
  • Adobe Creative Suite CS 2
  • Acrobat 3D
  • Acrobat Standard 7.0
  • Acrobat Pro 8.0
  • Audition 3.0
  • GoLive
  • Illustrator
  • InCopy
  • InDesign
  • Photoshop
  • Photoshop Elements
  • Adobe Premier Pro
These old versions are quite good and will match most of the casual users needs so it is a great catch.
The only problem is that within hours of the post, Adobe took down the download link and the reason is not very clear.
Either the amount of traffic on the adobe site was to much or they wanted to back down from the deal.
In any case, the link itself to the download is down(https://www.adobe.com/cfusion/entitlement/index.cfm?pid=4485850&e=cs2_downloads).

Slickdeals did step up to the plat and posted the direct links to the downloads from the Adobe site for us
http://slickdeals.net/permadeal/87488/adobe-adobe-creative-suite-cs2-standard-pc-or-mac-digital-download

download before the links go down as well.
A list of all the serial numbers can be found here http://pastebin.com/sDbdRLAN

Sunday, January 6, 2013

VTx and VTd on an HP Compaq 8200 elite machine

As I was setting up VMWare on a new system at work, I received an error stating "Virtualized Intel VT-x/EPT is disabled for this ESX VM" which I immediately translated to, I forgot to enable VT in the machines BIOS.

The Machine itself is a nice HP Compaq 8200 elite (fully loaded with graphics and memory).
After a simple restart I waited for the Bios advisory stating which button to press but the OS just booted up.
It seems that HP skipped the detailed boot screen to discourage home users to mess with these setting themselves.
A quick google search returned the solution to just press F10 after restart repeatedly until BIOS screen is received.

The BIOS itself is pretty simple, even too simple.
I have edited many BIOS's but for some reason for the HP compaq 8200 elite, could not find the VT settings.

Searching google again I found a lot of references claiming that if its not found the machine doesn't support VT.
Now This is so FALSE. We spent a lot of money on a machine with an i7 CPU and powerful motherboard just for that reason.
So i continued looking and found the setting.

Usually I don't post about simple Bios settings locations but since there was so much disinformation out there I felt the need to share the simple location.

To Turn on VTx and VTd on an HP Compaq 8200 elite machine,
1. Boot machine
2. Press F10 repeatedly until entering BIOS screen.
3. Go to Security Tab
4. Select "System Security"
5. Set Virtualization Technology (VTx) to enabled
6. Set Virtualization Technology Directed I/O (VTd) to enabled
7. To apply and save changes, select File > Save Changes and Exit.
8. Your done. restart and everything should be fine.

Good Luck.