Jesus Built my Minecraft Map

9 Feb 2012 In: Games, Minecraft

I am a lover of Minecraft. I go in spurts where I play it obsessively and then forget about it, only to repeat the cycle over and over.  Since I have logged so many hours, a lot of the novelty of the game has worn off.  Often times I will just create a map, and then wander and wander until I find something really interesting that inspires me to build.  A mountaintop lake, a floating island with a waterfall that I can swim up, that sort of thing.  Last time I was doing this, I was walking towards a hill when I saw a giant cross at the top.  When I got closer, I realized it wasn’t just a cross, it was a floating cross! Clearly my randomly selected seed was infused with the divine!

Pic so you know it happened:

Jesus minecraft screenshot

Rails gotcha using after_initialize hook and exists?

29 Nov 2010 In: Technobabble

While upgrading Ruby on Rails from 2.1 to 2.3, one of my models threw an ActiveRecord::MissingAttributeError exception when something used exists? to see if it was there. The issue turned out to be our after_initialize hook on the model. In our hook, we rely on looking up the value of one of the object attributes. This fails now because exists? only selects the primary key from the table, leaving the rest of the attributes undefined. Here is how we solved it:

  1. def after_initialize
  2.   do_something if foo_attribute
  3. rescue ActiveRecord::MissingAttributeError
  4.   reload
  5.   retry
  6. end

This will cause all the attributes to be fleshed out the second time around.

I wanted an easy way to encrypt and decrypt files in OS X from the command line, so I added the following to my .profile file in my home directory:

  1. enc() {
  2.   openssl des3 -salt -in $1 -out $1_enc
  3.   rm $1
  4. }
  5.  
  6. dec() {
  7.   openssl des3 -d -salt -in $1_enc -out $1
  8.   rm $1_enc
  9. }

Now I can quickly encrypt a file using ‘enc’:

  1. $ cat secret.txt
  2. this is a secret!
  3. $ enc secret.txt
  4. enter des-ede3-cbc encryption password: [password]
  5. Verifying - enter des-ede3-cbc encryption password: [password]
  6. $ cat secret.txt_enc
  7. Salted__?<?7sT?s??Cp??x?toA?d6~r?r

And decrypt it just as easily with ‘dec’:

  1. $ dec secret.txt
  2. enter des-ede3-cbc decryption password: [password]
  3. $ cat secret.txt
  4. this is a secret!

A couple of things to note. The encrypted file is saved using a _enc suffix, but when decrypting, it assumes you type the original filename, not the _enc version. I don’t mind this, but it could be altered to be a little smarter in this regard. Also, when encrypting it deletes the original file for you, and when decrypting it deletes the encrypted version. I prefer this automatic ‘cleanup’.

ThisDangHouse.org

3 Nov 2010 In: Uncategorized

Just a quick note to let people know I have started a new blog to follow the progress of my massive home remodel.  Join me on my adventure at This Dang House!

While building a Rest API call for our product, we needed the server to respond to a post with a “303 see other” response.  Unfortunately, in Rails when you do a redirect_to, it always uses the 302 response code, even when you set the status explicitly:

  1. redirect_to chunky_bacon_url(@bacon), :status => :see other
  2. redirect_to chunky_bacon_url(@bacon), :status => :303

These don’t fail, but they dont do what you would expect. In my test I asserted that the response code was 303, and the test failed.  After some digging I found that I could use the ‘head’ method to force rails to respond correctly:

  1. head :see_other, :location=>chunky_bacon_url(@bacon)

My response assertion passed. Yay. But it was short lived, because this assertion failed after I made the change:

  1. assert_redirected_to chunky_bacon_url(@bacon)

with an error deep inside response_assertions.rb.  Inside the ‘assert_redirected_to’ method, the following line failed because @response.redirected_to returns nil, and then explodes when it tries to call dup.

  1. original = { :expected => options, :actual => @response.redirected_to.is_a?(Symbol) ? @response.redirected_to : @response.redirected_to.dup }

I did some digging, and it turns out that when I used ‘head’ instead of ‘redirect_to’, the @response.redirected_to was never set.  I fixed the test by asserting string equality directly in the response headers:

  1. assert_equal chunky_bacon_url(@bacon), @response.headers["Location"]

Bitchin’ Kitchen: New paint job

14 Dec 2009 In: Project

In general, I find use of the word “bitchin” to be almost inexcusable. The sad fact is, however, that there aren’t very many good rhymes for “kitchen”, and I’m in a rhyming mood. At any rate, we decided to repain the kitchen, and quickly settled on a nice green for the walls, and then later decided to do one wall a darker purple. I am quite please with how it all came out, and hereby submit photographic evidence that I actually completed a project. For reallys.  I got all panoramic on you to give a better perspective of the room. Check the purple vent pipe too, it be stylin.

Purple and Green

Purple and Green

Of course, now that the paint is (almost) dry, I loathe my cabinets, I detest my linoleum floors, I despise my counter tops and I look upon my appliances with disdain.  Actually, the plan is to take the cabinets down in the spring, paint them white, and apply some of those stencil looking decals to them. That should help things out a bit.  The floors et. al. will have to wait, unless they give out before we are ready.

I also like the way our organization wall looks against the new green color, although the flash really washed the colors out.

Organization Wall

Organization Wall

OS X Tip, recover windows from external monitor

12 Oct 2009 In: Technobabble

So one latest OS X annoyance that I actually stumbled across the solution for. At work I hook up an external monitor to my MacBook Pro, and usually keep all my terminal windows on that one. When I leave, I try to remember to unplug the monitor before I close the lid, because last time I forgot to do that, I had to kill the applications over there and relaunch them to get access to them again.

I tried using expose, but that didn’t show the windows on the now disconnected monitor. I checked out the spaces dialogue as well, but that also didn’t work. I also went into the system preferences to the ‘displays’ screen, hoping to find the ‘gather windows’ button, but it was not present. I think you only get that button when an external display is connected.

The way I actually solved it was through app switching keyboard shortcuts. I used Cmd+Tab to switch to the inaccessible application, then used Cmd+~ to cycle through the windows. As each window received focus, a sliver of it appeared on the edge of my screen and I was able to drag it over.

Poor, poor snow leopard

26 Aug 2009 In: Observations, Technobabble
So Apple has released their new OS, Snow Leopard, and this is what the Apple homepage looks like:
Poor, poor Snow Leapord...

Poor, poor Snow Leopard...

I imagine this leopard, chillin, enjoying a nice snowy day, when along comes an Apple photo crew.

*FWAP*, they nail him in the head with a snowball, and as he looks at them with annoyance, they snap his picture.

I can only hope that shortly after this picture was taken, the Leopard ate every single one of them.

RFS: Good Home Design/Remodel Blogs

14 Apr 2009 In: Miscellaneous

RFS stands for “Request For Suggestions”.  I’m not sure whether I made that up or absorbed it osmosis like from something I read.

For those of you not in the know, I am soon going to be taking on a huge home remodel project, necessitated by some structural problems we are having.  In my quest for the ultimate abode, I am looking for inspirational resources.  I did the obligatory Google search and was disappointed with what I found.  I did find the Home Improvement Blog which has some promising looking content.  We all know about Apartment Therapy, which I love, but it’s a little like trying to sip from a waterfall.  I have also seen a lot of nice stuff on Inhabitat, but the architecture and design aspects of it are only a small slice of it’s content.

I am looking for blog’s that have the following types of content:

  • Floor plans and layouts for remodels
  • Finishing details for interior and exterior
  • Modern design that integrates well into old homes
  • Green building strategies
  • Logistics of remodeling (permits, pitfalls, etc)
  • Tips on ways to do things that look awesome, but don’t cost too much
  • Personal experiences in home remodeling projects
  • Photos, photos and more photos

If you can think of anything, please comment and help me out!

Rails Gotcha Regarding Test Fixtures

6 Mar 2009 In: Technobabble

I wasted a chunk of time running in circles over this issue.  I had assumed that when I loaded the fixtures into my database via ‘rake db:fixtures:load’ or ‘rake spec:db:fixtures:load’ in Ruby on Rails that it was blowing away all the data in all of my tables before creating records. It turns out that it only blows away data in tables for which you have fixtures, leaving any generated cruft in other tables behind.