Archives

All posts by Dennis

This post is meant to address the huge performance loss that can occur from the misalignment of a partition on a Solid State Drive, and how you can fix it.

Some months ago, I bought a Solid State Drive (OCZ Agility4 256GB to be exact) with the intention of using it for my operating system and everyday applications.  I wanted to transfer my existing Windows 7 install to the new drive, so my initial instinct was to clone the partition to the SSD rather than creating a new partition, installing a fresh copy of Windows 7, and enduring the long task of reinstalling all the software I need.  After some light research I found a lot of people saying that this was either downright impossible, or would horribly ruin the performance of my SSD.  I really did not want to install a fresh copy of Windows 7 so I went against the grain and decided to clone the partition anyway.

Continue Reading

I stumbled across this great website the other day.  Next time need an excuse as to why some critical code exploded in production, simply pop open developerexcuses.com and grab one of these:

Actually, that’s a feature

That code seemed so simple I didn’t think it needed testing

Nobody has ever complained about it

I’m surprised that was working at all

Better yet, just write a script that will automatically respond to Skype messages with excuses from this website!

The other day at work I needed to push only one commit out of several I had made locally to the remote server, for a release build.  Normally when one does a push, they push everything at once.  However, git does provide a way to push only one commit at a time.  The caveat is that the single commit you want to push must be directly above the tip of the remote branch (the oldest of your local commits).  If it is not, don’t worry as you can simply reorder your local commits to suit the situation.

SourceTree does not seem to provide any way to do what we want, but the command line interface of git does, and its actually pretty easy.  First you need to get the hash of the commit you want to push by using the command “git log” (Press “q” to exit the log).  A hash is a 40 character alpha-numeric string that looks something like  2dc2b7e393e6b712ef103eaac81050b9693395a4 .  Once you have the correct hash, use the push command as you normally would, except provide the hash as part of the command:

Important Note: This will push all commits up to and including the specified commit!  This means if you specify the commit that is at the top of your branch it will push everything, exactly the same as a regular push.  You need to reorder your commits first to make sure the commit you want to push is at the bottom (directly above the remote branch).  How to reorder commits with Git.

In place of the hash, you can also use standard Git revision names such as HEAD~1 or HEAD^, as well as abbreviated hash names.

There are lots of good reasons to change the order of your commits: sometimes they make more sense in a different order, or maybe you want to only push one commit out of several (more on how to do that soon).  Luckily, Git provides a way to do this, as long as the commits have not yet been pushed upstream to the remote server.  This is known as rewriting history.  I will explain how to do this with both sourcetree and git in a console.

Continue Reading

A somewhat specific problem that occurs often when developing for iOS and using SVN, is the need to escape the @ character.  The @ character is used with iOS and XCode to specify assets used for retina displays, by appending “@2x” to the end of the filename.  If you have ever tried to use a filename that contains an @ character with SVN, you likely would have encountered some trouble.  As soon as SVN sees the “@” in the filename, it seemingly ignores it and everything after it, cutting your filename short and causing an error.

Notice in the example above that everything past the “@” is missing in the warning message.  The problem is the @ character has special meaning to SVN; it expects everything after the @ to specify a revision number, so when it sees it in your path, it parses it out.  It gets trickier though, because escaping your path in the normal ways wont work, including surrounding it with quotes or using a backslash.

The workaround for this problem is simple and clever.  When parsing the filename, SVN only looks for the last occurrence of the @ character.  So if you add another @ character to the end of your filepath, the first one will stay intact.

Credit for the solution goes to gg1 at xappsoftware.com.

FDT supports special variables in the mxmlc compiler arguments when building a project, that allow you access to certain useful information.  Typically when you create a new project through FDT, you will get these two lines in the compiler arguments:

You can already see two variables being used here: {playerVersion} and {flexSDK}.  These variables are parsed before the arguments are sent to the mxmlc compiler, and would end up looking something like this:

Very useful!  So what variables are available then?  Unfortunately there does not seem to be any documentation about compiler argument variables, so I do not have a definitive list, but I do know of four:

  • {playerVersion} – The player version you selected when choosing the SDK for your flash project
  • {flexSDK} – The path to the selected flex SDK
  • {project} – The full path to the folder the project is located in
  • {locale} – The chosen locale (for example en_US)

I have not actually managed to get the {locale} variable to work, but I have seen it referenced in forums and in FDT bug reports, so I presume it at least works for some people.  There are a couple of variables that I would love to see added to that list that could be really useful, including the project name, swf filename and the name of the current build configuration.

Do you know of any other compiler argument variables that are available in FDT?  Please leave a comment if you do, and I will add them to the list.

Not everyone realizes it, but you can actually customize the context menu that appears when you right click a flash application in ActionScript 3.  You can add new items and you can even remove some of the existing items.  But lets get one thing out of the way first:

Can I remove or hide the Flash context menu?

The answer is no, you cannot.  There is no way to hide the context menu, and although you can remove some items like the print option, there is no way to hide the “Settings…” or “About Adobe Flash Player” items.  But lets go over what you can do.

Continue Reading

I recently ran into a quirk with the getBounds() and getRect() methods of DisplayObject, where the returned x and y coordinates would be extremely high (and incorrect) values.  This occurs when the DisplayObject is empty, using the following code:

Executing the above code gives the following result:

What?!  Where are these crazy numbers coming from?  Since childObject was added as a child to parentObject without having its x or y coordinates modified, you would expect that x and y would be 0, but instead we get the unexpected result of 6710886.4!  It is worth noting that if you try to get the bounds of an empty object using itself as the argument to getBounds(), x and y return 0 as expected.  Now if we were to add anything that has a width and height to childObject, say a vector rectangle or a bitmap, the resulting x and y values are 0 as expected.

I am not totally sure what is going on here, but if you need to get the bounds of a child DisplayObject, you may want to add a check to make sure that childObject.numChildren is greater than 0 first.