Category Archives: Techy

Programming! Also Linux, web design, hardware… But mostly programming.

go from model to associated table name and back

Given a table object, it returns the related string object; e.g. SubAttribute => ’sub-attribute’. Useful if you want to make a list of all your tables with perhaps their fields listed out to the side. Ruby def stringify_table( table, replace_char = ‘-’, pluralize = false )   string = table.to_s.gsub( /([A-Za-z])([A-Z])/, ‘\1‘ << replace_char.to_s << ‘\2‘ )   [...]
Also posted in Programming | Tagged , | Leave a comment | Current music Passenger Seat by Death Cab for Cutie

conditioner for ActiveRecord-friendly conditions from a collection

I frequently have a collection of values that I want to match in an ActiveRecord query, but it would be nice if I could let ActiveRecord handle checking the data and escaping it properly. So, I wrote this method to return ActiveRecord-friendly conditions, such as: ["user_id=? AND job_id=?", 3, 4] based on the ‘raw’ conditions you feed [...]
Also posted in Programming | Tagged , , | Leave a comment | Current music Hung Up by Madonna

XGL/Compiz customizations on Ubuntu

So I’ve got XGL/Compiz up and running and, I must say, it is hot. See the full entry for screenshots of what I’ve done so far. That’s the cube as I’m rotating it. That’s a photo of the city of Baltimore in the background with the capital dome on top of the cube. That’s the [...]
Posted in Techy | Tagged , , | 2 Comments

finally with the new computer

My case came! Freakin’ Newegg got on the ball and sent my replacement case, then Todd got my system put together and I’m installing Ubuntu 6.06 right now. It’s 61% done, and I’m so excited… Eee!
Also posted in Daily life | 2 Comments

XGL = hot

XGL/Compiz video comparison with OS X Spaces and Vista Aero. Watch those and see which one pwnz which one. I hope getting XGL and Compiz isn’t difficult on my new Ubuntu system.
Posted in Techy | Tagged , , | 2 Comments

simple Rails preference storage

So you’ve got some Rails application and you need to store information from the users across their interactions with the app. Here’s a simple, straightforward way to do that. In your controller: if params[:option]   @option = session[:option] = params[:option] elsif session[:option]   @option = session[:option] else   @option = 'default value' end This checks to see if ‘option’ was passed via a parameter in the [...]
Also posted in Programming | Tagged , , | Leave a comment | Current music Post Blue by Placebo

custom shapes in Photoshop

Custom shapes can be very useful for making multiple objects that look the same. For example, say you want several photos to all be cut out of the same shape, like this: Creating a Custom Shape Create a blank 200 pixels x 200 pixels image. Select the Rounded Rectangle Tool and set its radius to [...]
Posted in Techy | Tagged , , | 2 Comments | Current music They Dance Alone by Sting

new computer and a new layout

I put up a new layout! I’ve been wanting to do work on this site for a while now, but I never have any free time in which I’m not relaxing from work or class. Well, today I had a big full schedule of… nothing, so I decided to work on 3t7. [...]
Also posted in Daily life | Tagged | 8 Comments | Current music Beautiful Things by Andain

Illustrator rocks

Oh my goodness, I love Adobe Illustrator. I made this nifty thing in a few minutes:
Also posted in Daily life | 7 Comments

if succinctly

In Ruby, if is an expression, not a statement, thus it returns a value. This may not seem useful at first glance, but it lends itself to forming neat, concise code… Like most things in Ruby, actually. Setting Values Concisely Say you want to define a variable differently based on the result of an if [...]
Also posted in Programming | Tagged , | 2 Comments