Skip to content

Validating Rails boolean fields in RSpec


So I’ve working on a Rails app recently, using RSpec for Test-Driven Development, and I ran into what I think is a bit of a gotcha, so I thought I’d write up a post on the matter.

One of my models has a Boolean field, and like the other fields, I was trying to validate it using presence validation, and it was failing to be valid even with the initial value I’d set at the beginning of the RSpec file. So, what’d I do? I popped open the Rails Console to get a closer look at what was happening.


The case of the glacially slow computer


So, I recently ran into an interesting issue with trying to install Windows 7 64-bit on a PC. This one was quite a puzzler, and so I thought I’d share my experience, with the hopes that it will help someone else who’s desperately searching for an answer.

You see, this particular machine had been running 32-bit Windows XP for quite some time now (at least a few months, if not longer), and had been running fine. We decided to try and re-purpose the PC, and install Windows 7 64-bit on it, and that’s when we ran into trouble.

You see, whenever we tried to start installing Windows 7 on this particular machine, it would get stuck at the “Setup is starting…” screen. This happened with WDS, install from a USB drive, and install from a DVD. We hadn’t had this issue with WDS on any other computer, and that same DVD had been used for installing Windows 7 on other machines. (Side note: WDS skips the language select screen, but the other two methods had it freezing at the “Setup is starting…” screen after selecting the language and keyboard layout.)


When is a text file not a text file?


When it’s in the wrong encoding, apparently.

Allow me to explain. I was working on parsing (with Cygwin grep) a text file with which was created by copying the output of PsExec (one of the Sysinternals tools) and then running it through a PowerShell script to pull out and reformat the information I needed in a format that made it easy to parse with other tools. The issue I was running into was that grep kept failing to match anything. I even tried just matching against /./, and all I got for my trouble was a message that said that the “Binary file matches”, which was very puzzling considering it was a text file.

After searching around and pondering, the idea came to me that I should look at the character encoding. So I opened up the file in Notepad++, and checked the encoding, and sure enough, it was UCS-2 instead of UTF-8. I converted it to UTF-8, re-saved the file, and grep could then process the text file as a text file.

Just wanted to share this experience in the hopes that someone else will find it useful.

The case of the invisible bullet


Well, I promised some posts on gotchas I’ve encountered when making my first game. So here’s the first post in that series.

The game I’m making is a type of side-scrolling shooter. I have the “ship” being rendered using an image file, but I felt that it would be better to just draw a small circle to represent the bullets shooting out of the ship itself. I setup all the logic and just threw out a sample bullet, which never appeared.

Now, I’d had issues previously with the ship itself, where I’d forgotten to actually add it to the world I was rendering, but that wasn’t a problem here.

I could tell because I had some debug code enabled, which drew in the collision boxes around all the entities on the screen, and I could see the box around the bullet appear on the screen, just not the bullet itself. After poking around alot, I found my problem.

You see, playn.core.Canvas.setFillColor(int color) takes an integer color value, which can be represented as a hex value. I was supplying a hex color value for RGB directly to the function, but was neglecting to include a value for the alpha channel. As such, it defaulted to 0×00, which of course is transparent! D’oh!

In my searching I also found the nice playn.core.Color.rgb(int r, int g, int b) method, which takes three integer values (0-255) for red, green, and blue, and produces an integer color value with a fully opaque alpha channel value. Yay! ;) With that, the issue of the invisible bullet was solved.

Not quite all fixed yet…


Well, I’ve been busy here and there with other projects, my day job, etc., so I haven’t completed fixing the image links here yet. I will eventually get to that. ^^; However, I’ve decided (at the urging of a friend) to post about my progress in the game I’ve been making. It’s going to be my first game, so I’m learning alot. I think I’m mostly going to be posting about the gotchas and missteps I’ve made along the way, in hopes that they will help others.

サイト復活!It lives! ^_^


Well, after certain circumstances outside my control caused my site to go offline, I thought I’d lost it, but I managed to find the backups I’d made last summer. Hooray for backups! ^_^V Of course, most of my image links are dead as while I still have all the images, I didn’t have a backup of the Gallery installation I was using. ^^; So, it’s going to take a bit for me to get all the images fixed. So I would ask that you bear with me until I can get the broken images replaced. Thanks!

McDonald’s Japan Texas Burger


So, this year McDonald’s in Japan started a new campaign, called “Big America,” with a series of burgers themed after U.S. States. The first one, and the only one I’ve actually tried so far, to be honest, was the Texas burger. How is it? Well, I wouldn’t eat it again, but that’s just because I hate mustard. More…

Where has the time gone?


Wow, it’s been almost two months since my last post. Sorry about that folks, I got busy. XD
I’ll have another post up shortly, one I meant to post at the beginning of February, but never got around to it.
Edit: Also, I wanted mention that I’ve started using Twitter now. You can follow me on twitter if you like: @stephentigner.
I’ve been fairly active on Twitter recently, and it lets me send off short thoughts that I feel are too small for a proper blog post.



Well, I had a donburi meal at a restaurant tonight with the temporary roomate I have for orientation and his friends from SH 4. The gyudon I blogged about earlier is a donburi dish, but I’m not sure exactly what kind of donburi dish it was. ^^; It was quite good, and was served with some kind of katsu, or fried cutlet. It looks like alot of food to some, but for me it didn’t even come close to filling me, but it did sate my hunger at least. ;)

Yoshinoya Beef Bowl


I had gyudon (牛丼, also known as a “beef bowl”) yesterday at Yoshinoya. It was heavenly! For those who don’t know, it’s a bowl of rice served with strips of beef on top of it. Right now Yoshinoya (or at least the branch I went to) is having a “80 yen off” sale. So I got a large for 400 yen. They have three sizes, normal, large, and extra large. I think I’ll try the extra large the next time I go. :D The 80 yen-off sale is ’till the 21st. More photos in the January 18th gallery.