Wednesday, May 12, 2010

Clear improperly cached compile errors in FlexBuilder

If FlexBuilder is giving you a compile error that shouldn't be happening, and nothing you do seems to make it go away, it's possible FB is failing to clear its cache. Try going to:

workspace\.metadata\.plugins\org.eclipse.core.resources\.projects\<project>\

and deleting the .markers file. Restart FB and do a clean build.

Explanation after the break.

Thursday, March 25, 2010

Event testing helper for FlexUnit 4

I noticed a little while ago that assertions made in event handlers don’t work the way you’d expect in FlexUnit.  It looks like the event dispatcher wraps its calls to event handlers with a try/catch block and treats any errors it receives as unhandled (showing the exception dialog if you have the debug player installed, ignoring it otherwise).  This means if you have an assertion fail in an event handler it will not cause the test to fail.

Tuesday, February 16, 2010

Importing external scripts in same directory in Applescript

I started dabbling in Applescript the other day and rather quickly ran into an annoying limitation. Applescript has a mechanism for loading external scripts, but it requires absolute paths. I like keeping my code portable, and that means absolute paths aren't allowed. After some experimenting and digging around online I finally managed to find a solution.

Thursday, February 11, 2010

Asynchronous unit tests in FlexUnit 4

FlexUnit looks like a fairly decent Flex unit testing framework and we've started using it in our new Flex project. Unfortunately FlexUnit has pretty much zero documentation, so unless you can find a blog post from someone about how to do something you'll have to just figure it out from scratch.

My coworker and I end up having to dig into the FlexUnit code occasionally to figure out how things work. The latest instance of this for me was to try and figure out how to test asynchronous events. I found a couple posts showing that it was possible with basic examples, but no real explanation of the different options.

I've managed to get a few different types of async tests working, so I figured I'd give examples of the different async methods provided by the Async FlexUnit class.

Thursday, February 4, 2010

Shortcut for enabling/disabling wireless device (or any device)

Most laptops these days have a switch or button to toggle the wireless device.  Turning off wireless is a good way to save battery, and having a shortcut to turn it off is nice.  The switch on the previous laptop I had would completely turn off the device.  However, the new laptops we got at work seem to only turn off the antennae.  Power-wise this is fine, but Windows continually opens one of the bubble notifications to tell me that the wireless isn't connected.

Nothing is broken, but it started getting really annoying to have to dismiss that notification a couple times an hour.  Extra annoying is the fact that Windows provides a checkbox that looks like it should turn that behavior off, but even with that unchecked it still bugs me.

Friday, January 29, 2010

Open Cygwin/Powershell Here directory context menu entrys

For years one of the first things I installed on new windows machines was the Open Command Window Here powertoy. I'm not much of a fan of cmd and generally use cygwin for my command-line stuff, but the ability to quickly open a terminal at a particular directory was very useful.

Lately I've started to use powershell in place of cmd wherever I could. I still don't like it nearly as much as I do cygwin (probably mainly due to familiarity), but it's a lot better than cmd. I also use it in cases where cygwin doesn't play nice with windows command-line apps.

Saturday, January 23, 2010

SortedQueue in Ruby

I've started working on the solver class for my ES project. I'm essentially implementing Dijkstra's algorithm where the graph nodes are the different board states and the edges are the turns. It's a little different as I'm generating the graph while traversing it instead of starting with a known graph.

One of the data structures required for implementing Dijkstra's algo is a priority queue. A strict priority queue won't quite work for me, as that requires numeric values for the priority, which I don't have. Instead I've defined a compare function for my nodes and want the queue to simply be sorted based on that.

Wednesday, January 20, 2010

Quickly check out all files in TFS that contain a certain string

We use Team Foundation Server at my place of gainful employment for source control and bug tracking.  It's adequate for both tasks, but isn't what I would prefer.  One of the reasons I don't really care for it is that it doesn't integrate well with most of the tools I use.

If I'm working on the C++ dll then it actually works rather well, as I'm already using Visual Studio as my IDE.  Any time I need to change a file it automatically checks it out.  Sadly I don't get any of that automation when working in netbeans or flex builder (yes, there's an eclipse plugin for TFS, but it's $200 and I'm not quite _that_ annoyed with it).

Today I needed to refactor a class in my Flex code that's used in a number of places.  The refactor included moving the class to a new package and renaming it.  FlexBuilder could handle the refactor, but couldn't handle checking out all the files it needed to modify.  Doing so manually was also annoying, as I'd first have to grep for all the files it would need to change and then find them in TFS to check them out.

Friday, January 15, 2010

How I learned to stop worrying about types and typos in ruby.

I had a bit of an "aha!" moment earlier while working on my ES project that helped me get over one of the major sticking points I had with dynamic languages like ruby.  But I'm going to make you read through some background before I actually share the moment itself.  If you don't like it, well, too bad.  You'll just have to skip a paragraph or three.

Saturday, January 9, 2010

Improving ImmutableProxy

My initial version of ImmutableProxy worked perfectly for methods that were specific to the object being wrapped, but it didn't work properly for the built-in Object methods.

Most of the built-in object methods aren't actually used in my code and probably aren't needed by the players, so I didn't want to waste time overriding them all.  But some of the basic ones were needed, like eql?, and is_a? (is_a? is used by the eql? methods defined by the classes being wrapped).

Friday, January 8, 2010

Easy immutability in Ruby

One of the first paradigm shifts (did I really just use that term?) I ran into when going through ruby koans was the idea that function calls are actually just messages being passed between objects.  Though I had heard of this idea before I'd never actually dealt with it, and at first I wasn't sure what the big deal was.  The about proxy koan showed how to create a basic proxy class, but the utility of such a class wasn't immediately apparent.

Tuesday, January 5, 2010

Extreme Solitaire

After finishing Koans I was looking for another project I could work on to help learn ruby. Unfortunately I had a lot of trouble coming up with an idea for a project to work on. All the tools I've needed recently have already existed, and since I actively needed them it made more sense to use what I found than spend the time to create one.

Sunday, January 3, 2010

Unit tests, as a learning tool?!

As I mentioned before the first project I looked at for help learning Ruby was  Ruby Warrior.  It was a great idea for a way to get into programming Ruby, but as someone who didn't even know much of the ruby syntax I had trouble discovering how to write the code I wanted to write.

Then I remembered a project my friend had mentioned to me earlier.  This project was Ruby Koans.  Koans is a collection of unit tests where most of the code is written, but the expected values in all the asserts are left blank.

Saturday, January 2, 2010

Syntax Highlighting and Blogger

I spent an hour or so poking around trying to get code highlighting working in blogger.

My first attempt was to use tohtml, which I've used at work a number of times to get colored code to paste into Outlook when doing code reviews.  It does code highlighting for a TON of languages and generally creates stuff that looks pretty good.  The coloring options aren't too impressive, but they work.

My intro to Ruby

I started poking around with Ruby a month or so ago.  Prior to this I had seen a little bit of ruby code but had a lot of trouble following it.  I had modified a single line of Ruby in a documenting tool I was using for my Actionscript 2 code, but that was just changing a false to a true and doesn't really count.

My first real involvement with Ruby was to join my friend and coworker Matt at the December meeting of the Pittsburgh Ruby Users Group.  I was worried that everything would go over my head, but the guys and gals there were quite helpful.  I ended up learning about a couple ruby projects that helped get me into writing Ruby code very quickly.

Friday, January 1, 2010

Who are you? How did you get in here?

I mean seriously, I just created this thing. How'd you already find me?

Well, doesn't matter. You're here now. Or you aren't and I'm just talking to myself. But that's not unheard of, so...onward!