Courtesy of Twitter

Archive for May, 2008

Availability is unavailable

Thursday, May 29th, 2008

http://thesaurus.reference.com/search?r=20&q=availability

See for yourself.

Mac: The First Two Hours

Sunday, May 25th, 2008

So today as a kind of a reward for working hard and kind of I’ve always wanted one, I bought myself a MacBook Pro. It’s a 15.4″, 2.4ghz, yada yada, brand new MacBook Pro.

I took the train in to town (after being placed on hold for 10 minutes) and, thanks to Google Maps’s wonderful position of Next Byte (saying it was on the southern side of Rundle Mall when it was actually on the northern side), I accidentally stumbled into the store whilst looking for it. The guy who served me was more than happy to go upstairs and get one… but when he returned the serial number didn’t match. So he went to get another… and the serial number still didn’t match! Each time taking about 3 minutes. Third time lucky, he came back and said “I know this is in the system”, and I bought it on the spot. 

It’s now two hours after I’ve gotten home. It was weird at first having a perfectly good computer in front of me and not knowing what to do with it, but once you play around with it for a little while things (simple and not so simple) become obvious. The dock is probably my favourite feature so far, even if I did have to make it about 33% of it’s original size. I’ve also managed to install Git!

 

The downloads box is another good feature, but it needs some more notification, like what the Colloquy window has when someone says your name. I love the way you install programs, so non-fuss. I click once on the downloaded file and it’s already there for me to use.

If the ambient light is bright enough, the keyboard keys are not illuminated and the screen gets brighter automatically so you can see in lighter conditions. There is a certain limit to how dark the screen gets, so you’re not going to be adjusting the brightness if you’re sitting in a dark cave somewhere.

The magnetic power plug is good too, and I know full well the damage that can be caused to a laptop when you trip over a cord that’s plugged into one; I recently destroyed the headphone socket when I tripped over the cord coming out of my Toshiba laptop. I know that if I trip over the Mac’s power cord, it should come out right away. The annoying thing I find about it is the light… but I guess I’ll get used to that.

The terminal was originally hard to find (I am/was/will be a Mac Noob), but eventually I did. I love how the commands are so unix like, such as sudo to do stuff as root and… just about any unix command you can think of.

Another nice touch is having the menu bar at the very top of the screen rather than the application, so whatever application you’re in it’s always in the same spot and generally the menus seem to be laid out the same way.

One last thing, *everything* looks so god damned shiny. It’s awesome. The fonts are all anti-aliased (except the terminal’s by default, not too hard to change) and the buttons all have that classic Mac styling we’ve come to love and envy.

All in all, a very nice system and worth the money.

 

URLs

Tuesday, May 20th, 2008

Why do people worry so much about pretty URLs, seriously? It’s a tedious waste of time.

And then there’s those people who (obviously) don’t know about the POST method and chuck huge Bible-sized attributes in their URLs.

I’m confused.

Updating a select box based on another

Tuesday, May 20th, 2008

In two projects now I’ve had to use code where I update a select box (machines) in regards to what’s selected in the first (customers). mark[oz] from #rubyonrails asked how to do this last week and I told him I would write a blog post the following night. 5 days later, here it is.

I use this when I’m creating a new call and the user needs to select which customer and then which machine. I have the following in my CallsController:

def new
 
@call = Call.new
 
@customers = Customer.find(:all, :order => "name ASC")
 
end

Relatively simple. We instantiate a new call object so the form knows where to go, and we define @customers so the first select box has some information.

Of course in our Customer model we have:

class Customer < ActiveRecord::Base
has_many :machines
end

And the machine model:

class Machine < ActiveRecord::Base
belongs_to :customer
end

These define the relationships used within the system.

Next is the new.html.erb page itself.

<strong>New Call</strong>
<% form_for @call do |@f| %>
<%= render :partial => "form" %>
<%= submit_tag "Create" %>
<% end %>

And a stripped-down version of the form partial:

<%= @f.label "customer_id" %>
<%= @f.select "customer_id", @customers.map { |c| [c.name, c.id] }%>
<%= observe_field "call_customer_id", :url => by_customer_machines_path, :with => "customer_id" %>
<%= @f.label "machine_id" %>
<%= @f.select "machine_id", "Please select a customer" %>

Right now that we have the form all set up, lets set up our machines controller

class MachinesController < ApplicationController
#CRUD operations go here
 
def by_customer
@machines = Machine.find_by_customer_id(params[:customer_id])
end
end

And our by_customer.html.erb:

<%= options_from_collection_for_select(@machines, "id", "name") %>

And finally the config/routes.rb:

map.resources :customers do |customer|
customer.resources :machines
end
 
map.resources :machines, :collection => { :by_customer => :post }

Now when we select a customer from the top drop down, the machines drop down should be populated too.

RadarLAN

Monday, May 19th, 2008

We (me, Paul, Thomo, Kellow, Steve and Cam) had another RadarLAN on the weekend and it was so much fun killing you all in CoD4 by calling in airstrikes and helicopters and accusing (rightfully!) Thomo of hacking in Trackmania that I’ve decided to try and hold one every 4 weeks. This means the next one would’ve been on the 21st June, but I’ll be camping it up in Sydney then, so instead it will be on the 14th June.

Consider this your three weeks notice! No excuses that you didn’t get the notification, because you should’ve read my blog, like all the good other people!

Want to know more information about it? Mail me at radarlistener@gmail.com.

ActiveResource & ZenDesk

Wednesday, May 14th, 2008

With many, many thanks to Frederick Cheung, who without this would’ve been way more painful and time-consuming. My original question and our discussion can be found here.

At my new job we signed up with ZenDesk, which acts as our helpdesk/ticketing system for our clients who sign up to our site and buy our product. Because ZenDesk uses emails instead of plain ol’ usernames for authentication, Ruby chucked a fit when we tried doing stuff like:

class User < ActiveResource::Base
self.site = "http://ouremail@ourwebsite.com:ourpassword@ourplace.zendesk.com"
end

Ruby’s URI class just didn’t like that first @ sign in there! So Fred originally recommended we try to encode it, %40. That didn’t work. Then the next morning Fred suggests doing this:

class User < ActiveResource::Base
self.site = "http://ourplace.zendesk.com"
 
def (self.site).user
"ouremail@ourwebsite.com"
end
 
def (self.site).password
"ourpassword"
end
 
end

And ‘lo and behold the thing worked!

So for all you savvy kids using Rails’ ActiveResource and trying to make it play nice with ZenDesk, that’s how we did it.

Then I went a little further with the refactoring and just made a ZenDesk model:

class ZenDesk < ActiveResource::Base
 
self.site = "http://ourplace.zendesk.com"
 
def (self.site).user
"ouremail@ourwebsite.com"
end
 
def (self.site).password
"ourpassword"
end
 
end
end

And then got the models I wanted to inherit from that.

class User < ZenDesk
end

Brilliant!

Also one more note. If you’re going through and testing out creating Organisations/Users in ZenDesk through ActiveResource, don’t forget to delete them as you go! It’s time-consuming clicking edit, and then the delete button for 50 odd objects… but of course you could do this:

for i in original_object_id..last_object_id
User.find(i).destroy
end

Which, if you did it, say, all in the same day like I did, should delete all the users within that range.

The Many Faces of…

Thursday, May 8th, 2008

Hilary Clinton.

The only woman candidate in the 2008 United States “Let’s-See-How-Long-We-Can-Drag-This-Out-For” Presidential campaign.

Sam Kekovich once stated that “Helen Clark does a passable impersonation of a man”, and obviously Hilary Clinton wasn’t on his mind at the time. I just hope Hilary doesn’t do what Bill did especially with another woman; more shocking it would be if it was with the same woman.

It surely is skillful to have as many facial expression as Ms. Clinton, but how is that going to help the American economy? We all know how bad women are with spending. Would you give one woman the control over an entire country’s wallet? I wouldn’t.

Let’s just hope if she’s elected she won’t decompose into Yet Another Old Person unlike a certain other candidate.

Job

Tuesday, May 6th, 2008

Beginning next week Monday 9am I have a new job. It’s with a company called NetFox who provide a firewall-like solution to many education facilities, like the local universities and my old school. They also have many other projects they are working on.

That is all.

Sheer Coincidence

Thursday, May 1st, 2008

Today I was going to put on my music, but I’ve listened to all the good stuff in there over and over again. I was thinking of putting on Finger Eleven’s Paralyzer as it’s a catchy song, so I started humming the chorus as I turned to my radio to turn it on.

Not only was it that song on Nova, but it was around a second past where I was just humming it. Freaky.

Also a few years ago, at a family gathering and after Grandad had passed away, the conversation changed topic to his girlfiend, Shirley. No one had heard from her for at least a year, and a few people said they’d seen her in the shops. During this conversation, Aunty Eileen gets a call on her mobile and we joke “Oh that’ll be Shirley”. Surely enough, Aunty Eileen goes “Oh, hi Shirley”, loud enough for the room to hear over the conversation.

Anyone else had something like this?