0

Do certain languages attract bad developers?

Posted by admin on Aug 27, 2009 in Uncategorized

Why is it that every time I come in to fix a VB project, the code is awful?  This current one is probably the worst.  It is sloppy.  It is riddled with security vulnerabilities.  it is filled with files named “checkout.aspx”, “checkout2.aspx”, etc.  No source control.  No dev or staging enviornment.  They were using the production database for development. They don’t understand the concept of reuse or refactoring.  I fixed the exact same bug 20 times because they have cut and paste this code everywhere.   I’m not getting paid to clean up the code, just fix the vulnerabilities.

So my question is why does VB attract so many BAD developers. Javascript tends to do the same thing.

Why?  You can write really good javascript code.  You can write really good vb code (although it will always be ugly).  I just don’t understand why every vb project I look at appears that 10 year olds wrote it.

Now that I think about this some more, I’ve seen some really really horrible C++ code too.  I’m going to have to think about this one.  I’m just so tired of cleaning up after VB coders.

 
0

Login failed after restoring database on SQL Server 2008

Posted by admin on Aug 24, 2009 in Database, SQL Server

After restoring a production database backup on SQL Server 2008, to my development machine, I got a “Login failed for user xyz”. The database user was not associated with a user and was marked as “Without login”. This happens when you do not have a login for the database user.  You can create that user but the SIDs do not match.  SQL Server provides a stored procedure to check for this scenario.

sp_change_users_login ‘report’

To correct it, use the same stored procedure with a different command.

sp_change_users_login ‘update_one’, ‘{username}’, ‘{login}’

This will make sure that your username and login have the same SID.

 
0

parsing xml using C++ on iPhone

Posted by admin on Aug 23, 2009 in C++, iPhone

I am trying to import an X3d file into my iPhone application. I could use the NSXMLParser to do this, but I want to write as much of the application logic in C++ as possible. The reason I want to do this is that I would like to be able to port this application to a different platform in the future. NSXMLParser is only usable from Objective C. the iPhone has the libxml2 installed . This is an xml parsing library with a generous license (MIT).

In order to use it, you will need to add the library to your project.  I created a “libraries” folder and right clicked it.  Select “Add > Existing Frameworks”.  Navigate to /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk/usr/lib/libxml2.2.dylib.

You then need to add the following include directive in the file you want to use it:

#include <libxml/parser.h>

You need to add the library to your project search path.  Open project properties.  On the build tab, find “Search Paths” > “Header Search Paths”.  Add “/usr/include/libxml2″ to this path.  You should be able to compile and use libxml2 now.

 
0

Installing scripts in blender on MacOSX

Posted by admin on Aug 22, 2009 in Mac

Needed to edit a script for Blender to figure out why I can’t get it to export textures in the x3d format.  All the help on the web say to look for it in .blender/scripts but I couldn’t find such a folder on my machine.  It wasn’t in my home directory and it wasn’t in the blender folder.  This folder is actually located inside the blender.app package.  So, to edit these files or copy them you can’t use finder.  Open up a terminal and cp to where you installed Blender.  I installed it in “Applications” in a “blender” folder.  So,

cd /Application/blender/blender.app/Contents/MacOS/.blender/scripts

This is where you will find all the scripts for blender.

 
1

code sign error The identity doesn’t match any valid certificate

Posted by jason on Aug 22, 2009 in Objective-C, iPhone

I am currently going through some tutorials for the SIO2 game engine I am currently evaluating.  I was able to run the code just fine on my iPhone simulator.  When I went to deploy this tutorial to my iPhone device, I got a “Code Sign error: The identity ‘iPhone Developer: Romain Marucchi-Foino (VC824XU999)’ doesn’t match any valid certificate/private key pair in the default keychain”.

To fix this so I could deploy, I clicked “Project > Edit Project Settings”. I changed the Code Signing Identity to point to my cert.  I got the same error. I searched the file system to try and figure out where that string was coming from.  In Visual Studio, sometimes I have to edit the project file with a text editor to fix weird issues like that.  So, I opened up the *.xcodeproj file to see if I could find it there.  I use TextMate for my Ruby code so I fired it up to open that and it turns out that *.xcodeproj is not a file but a package or directory or whatever Mac fanboys call it.  Inside I found the project file and found the string.  I wanted to figure out how to fix this through the UI so I didn’t just change the text there.  I did notice though that the old cert was listed under a different profile.

So, back in the project properties, I selected “All Settings” in the configuration drop down and changed the cert once again to my cert and everything worked!

UPDATE: Well, It happened to me again but this time, changing the code signing cert didn’t help.  I had to go into the actual project file by right/command clicking on myproject.xcodeproj and selecting “Show Package Contents”.  Edit project.pbxproj with a text editor.  Search for: “CODE_SIGN_IDENTITY[sdk=iphoneos*]” = “iPhone Developer: Romain Marucchi-Foino (VC824XU999)”;  Replace all of these with your own identity.  for me it was: CODE_SIGN_IDENTITY = “iPhone Developer: Jason Rowland (2RK77WERHG)”;  Save the file, and go back to xcode.  It will prompt you to reload from disk and say yes.  Maybe another day I’ll figure out where the setting is in the GUI but now that I know I can change these things with a text editor, I probably never will :(

 
0

Gas guzzling hog vs. Chevy Volt

Posted by admin on Aug 11, 2009 in Uncategorized

I recently read a USA Today article talking about the Chevy Volt.  In this article, they mentioned 230 mpg which sounds awesome.  Later in the article, I read that the Chevy Volt would cost about $0.03/mile to operate.  I have a neighbor that wanted to sell both of his cars and buy hybrid vehicles to save money.  I really wish people used their brain before they made ridiculous statements like that.  If you want to buy a Chevy Volt to cut down on our national dependence on Oil, fine.  If you want to buy it to cut down the green house gases, ok.  But don’t buy a Chevy Volt thinking you are going to save money. Buying a new car can never be justified by the finances alone.  It is better to buy used than to buy new in terms of bottom line dollars.  We will take my used 1999 Dodge Durango for worst case comparison purposes.  It is a gas hog but it will tow a boat quite nicely thank you.  Let’s do the math…

Gasoline

MPG seems to be the only thing that these articles focus on so let’s start there.  The VOLT is expected to get 230MPG.  The actual MPG is typically 15%-20% less than the reported MPG.  So that 230MPG is actually 195MPG (still awesome).  According to the EPA, the average passenger vehicle is driven about 12,000 miles per year.  So the cost per year of gasoline for the Volt will be (12,000 miles / 195 MPG) * (2.50$ per gallon of gas) = $153/year in gasoline.  Wow.

Like I said, my Dodge Durango is a gas HOG.  I’ve calculated the gas mileage ad I can’t get it above 12MPG.  The cost of gasoline is (12,000 miles / 12 MPG) * ($2.50 per gallon of gas) = $2,500/year in gasoline.  This means over the course of 6 years I will spend $15,000.  Ouch.

Note: I put closer to 8,000miles/year on my Durango,  so it really doesn’t cost me that much in fuel.

New vs. Used

According to J.D. Power, the average length of time a consumer owns a vehicle is 6 years. In order to compare these vehicles to see which one is cheaper, we will assume we sell this vehicle at the end of 6 years. According to consumer reports, the depreciation on a car for the first 6 years is roughly 70%. This means six years later, your new car will be worth 30% of what you paid for it.

The cost of a new Chevy Volt will be $40,000. 6 years later, it will be worth $12,000. That is a decrease in net worth of $28,000. Used Dodge Durango with 120,000 miles = $4,280. For this comparison, we will just assume you have to pay someone $50 to haul it away after 6 years. Not really fair since I’m still driving a 1994 Pontiac Grand Am and it has some value.

This right here is the real issue with the ownership costs of the Chevy Volt.  It isn’t specific to the Volt.  Really, this article boils down to new vs. used.  This right here is why if you are trying to save money, you should go out and buy a cheap gas gusling clunker instead of that shiny new hybrid.

Maintenance

Cars break down.  Older cars break down more often than newer cars.  I have no idea how to even quantify this.  My Durango doesn’t really go into the shop very often.  My 15 year old Grand Am goes in more regularly so I will use it to estimate my future Durango costs.  My Grand Am seems to break down a few times a year now and cost me $300-500 each time.  I am just going to use $1,000/year as a guess.

According to Consumer reports, repairs cost about 4% of the total cost of ownership in new cars for the first five years so I’m just going to use 4% of the depreciation of the vehicle. This works out to be about $1,120 over the course of six years. The actual repair costs will probably be higher since consumer reports only measured a five year period.

Sales Tax

Consumer Reports used national average of 4.9% to determine the sales tax in their evaluation of total cost of ownership.  I’ll do the same.  Chevy Volt sales tax is $1,932.  Sales tax on a used Durango is $206.

Interest on loan

I don’t think it’s a good idea to borrow money for a car, but that is a different post.  Since most Americans have car payments, I will factor it into this discussion.

According to J.D. Power, the average length of loan for a car is 5 years. Consumer reports used a 15% down payment and 6.8% interest rate to determine interest on the loan.  Using these numbers, the interest for a $40,000 Chevy Volt is $6,200.  Interest on the Durango would be $660.

Government subsities

The government will give you some of my money to buy yourself a new Volt.  They will give you $7,500 in fact.

Insurance, Registration Fees

All these would be higher for a new car. I’m feeling lazy so I’ll be generous and assume they are equal. Just keep in mind that insurance alone would be quite a bit more for a $40,000 car vs. a $4,000 car.

Adding it all up

2009 Chevy volt 1999 Dodge Durango
Capital Expense $40,000 $4,200
Sales Tax @4.9% $1,960 $206
Loan Interest @6.8% $2,720 $660
Gasoline @$2.50/gal $153/yr = $918 $2,500/yr = $15,000
Maintenance $1,120 $1,000/yr = $6,000
Government Subsidy -$7,500 0
Resale after 6 years -$12,000 ($12K in my pocket) $50 (tow away cost money)
Total Cost of Ownership $30,218 $26,116

Conclusion
Don’t buy a brand new hybrid expecting to save money in the long run. The math does not work. If you want to buy a hybrid for enviornmental concerns, then by all means. But don’t try to justify your purchase as a cheaper alternative. I used one of the worst possible vehicle to compare. I gave the hybrid every benefit and made assumptions in it’s favor. I used the government subsidy. I did all these things and the Durango still beat the Volt by $1,000. If I used a 1999 Pontiac Grand Am for comparison, it would be $15,000 cheaper than the Volt over 6 years.

Just to be clear, I’m not against hybrid vehicles and I want our country to be cleaner and free from dependence on foreign oil. I just don’t appreciate articles that distort the financial picture of these vehicles like the USA Today did claiming $0.03/mile. The total cost of the Volt is much much higher. Of course, if they factored in the actual cost to secure foreign oil, this would be a different article.

 
0

Windows Mobile 6 Signed Cab displaying “Program is from an unknown publisher”

Posted by jason on Aug 11, 2009 in Windows Mobile

UPDATE:  Apparently, there is a different technology than Authenticode that I should be using for Windows Mobile.

After signing the EXE and the CAB file, this worked just fine on Windows Mobile 5.  When testing on Windows Mobile 6, I got the following error: “program is from an unknown publisher”.  Not only must the EXE and CAB file be signed, but all the DLLs inside the CAB must be signed too.  There are two ways to accomplish this.

The first method is to simply add the signtool commands mentioned in my previous post to sign the DLLs.  Aftter the DLLs are signed, you cab up all the files using CabWiz.exe. Then you sign the cab file itself.

The second method is to use the utility CabSignTool.exe from Microsoft.  This handy utility explodes a CAB file, signs every executable and DLL file inside, then recabs it and signs the CAB file.  In order to use it, you will need to download and install the Windows Mobile 6 SDK.  The tool is located in <WindowsMobile6SDK>/Tools/Security/CabSignTool.  Make sure this is in your path.  The cabsigntool takes most of the same arguments as the signtool.  The only differences are that the first two parameters are the input and output cab names and the “sign” command is not necessary.  So to accomplish signing the cab, do something like the following:

c:> cabsigntool.exe cabinput.cab caboutput.cab /f [yourcert.pfx] /p [yourpassword] /t [yourtimeserver]

When you execute this command, it will extract the contents of your cab file.  It will sign each file inside.  It will then recab the files and sign the cab file.  So you can accomplish with one command what it took multiple lines to do with signtool.exe alone.

http://msdn.microsoft.com/en-us/library/aa924367.aspx
http://msdn.microsoft.com/en-us/library/bb278115.aspx

 
1

Windows Mobile application signing

Posted by admin on Aug 10, 2009 in Windows Mobile

UPDATE:  Apparently, there is a different technology than Authenticode that I should be using for Windows Mobile.

Most of the documentation to sign code for the Windows Mobile device assumes you want to do it all through the Visual Studio enviornment.  Well I don’t.  Here is what you need to do to get your application signed as well as the install cab created and signed using the command line.

First, get your certificate from verisign, godaddy, or some other certificate authority.  Follow their directions to install it in your store and create a *.pfx file.   I used godaddy http://help.godaddy.com/article/5087.

Sign the exe using the signtool.exe

signtool sign /f {yourcert.pfx} /p {yourpassword} /t {http://yourtimeserver} {yourexe}

Second, You will need an ini file that cabwiz.exe will use to create the cab file.  The easiest thing is to create a SmartDeviceCab project and use Visual Studio to determine what you will install on the device.  When you compile this SmartDeviceCab project, it creates an ini file.  You use this ini file to create your CAB file as your starting point.  Run the following command to create the cab file:

cabwiz.exe your.inf /cpu CEDevice /compress

After you have created your cab file, you can then sign the cab file the same as you signed your EXE.  That should be all there is to it.

 
0

Windows Mobile i18n fun

Posted by jason on Aug 10, 2009 in Windows Mobile

Looks like I’ll be doing some Windows Mobile development again since it is going to pay the bills for a bit.  Working with CloudSync on their GPS Logging utility.  The devices basically log the GPS data at 5 second intervals.  This data is then sent in batch to the servers for further processing.

The issue I worked on was making sure the data gets the server in a format that the PHP folks can recognize.  Internationalization (i18n) created a problem because the dates and numbers were being sent in a different format. In Chile for instance, the dates and numbers were not coming out as we expected.

currentLatitude.ToString("#0.00000");
// this came out as 0,00000


gpsTime.ToString("MM/dd/yyyy HH:mm:ss");
// This came out as MM-dd-yyyy HH:mm:ss

Apparently, .NET converts these for you based on the NumberFormatInfo object and the DateTimeFormatInfo objects.   I thought an easy way to correct this would be to set the current thread locale to be that of US so I could send the data in the expected format.  In the full .NET world, you could write something like this to accomplish it:
http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo(VS.71).aspx

Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

Unfortunately, the CurrentCulture property on the thread object is not available in the compact framework.  Instead, you need to pass the culture object along with the format in the toString methods. You could create a CultureInfo object such as “en-US” and pass this, but .NET provides a better alternative.  The CultureInfo object has  a property called InvariantCulture.  Using this object ensures that the behavior is consistent across all the different cultures.

currentLatitude.ToString("#0.00000", CultureInfo.InvariantCulture);
gpsTime.ToString("MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

After doing this, it is exactly as one would expect.

Copyright © 2010 programming with passion All rights reserved. Theme by Laptop Geek.