Verbose Logging

software development with some really amazing hair

21 Aug 09

08:00 AM MDT

Posted in Programming

respond_to with respond_glue: override respond_to

So check this: you have a nice little Rails app. You have some stuff for a JSON API type system. You’ve got an STI setup with the Widget model class and the more concrete FancyWidget and WeirdWidget classes. You’ve got a WidgetsController, and the corresponding FancyWidgetsController and WeirdWidgetsController Yay. It works. You can deal with both types of Widgets using JSON. Now you need an HTML interface to it. Fine, you can just throw in a ...


Read the full article

Comments

25 Jul 09

06:00 AM MDT

Posted in Programming

Worth watching. Twice. Uncle Bob Martin @ RailsConf '09

Robert Martin’s “What Killed Smalltalk Could Kill Ruby, Too” talk at RailsConf 2009. Yeah, so if you could just go ahead and turn Javascript on, that’d be just great…


Read the full article

Comments

15 Jul 09

08:00 AM MDT

Posted in Programming

Simple jQuery timeout

I needed jQuery to fadeout an item after a certain timeout, and I found it odd that I couldn’t find a native jQuery way to do it. Whatever. jQuery is so awesome that it doesn’t matter, because here’s what I came up with. EDIT 28-Nov-2009 In retrospect, all I wanted was a jQuery like syntax, but leveraging jQuery to do the timeout is sort of wrong. After all, Javascript does have a setTimeout function. I must have been in a jQuery must do all o...


Read the full article

Comments

14 Jul 09

08:00 AM MDT

Posted in Programming

role_on: Really Simple Roles (for Rails)

I looked at a few role systems for Rails, but never found what I wanted. They were all object based systems, never just “allow a user with this role to do this action”. Either that or I never found the systems that did that, or totally missed the docs on how to configure those systems to do what I wanted. Well, actually acl9 seemed to do that, but whatever. So I made role_on The instructions are on Github, so I won’t repeat them here, but it’s...


Read the full article

Comments

11 Jul 09

08:00 AM MDT

Posted in Programming

apt-runner: Just install it for me, please!

Picture this: You are reading some tutorial or whatever, and you need to install some things. So you run ‘aptitude install prog1 prog2’. Then you realize you need prog3 and 4 too, so you CTRL+C that, and run ‘aptitude install prog1 prog2 prog3 prog4’. Then you see you need something else. Rinse and repeat. This is really annoying. The worst part is you can’t run multiple aptitude instances, because they’ll whine about file locks or something. ...


Read the full article

Comments

09 Jul 09

08:00 AM MDT

Posted in Programming

Wordpress Multipart Posts, Inlined with jQuery: Part 2

(See Part 1) And we’re back! So, just take a look up below the title…see that little link? Yeah go ahead and click that. If I did my job right (tested in Safari on Windows, Chrome, FF), the contents for Part 1 should slide in above this post. In this post, since I use the Textile 2 plugin, I add this snippet at the top: (See "(remote-inline)Part 1":/2009/07/08/wordpress-multipart-posts-inlined-with-jquery-part-1) In textile land, that translat...


Read the full article

Comments

08 Jul 09

08:00 AM MDT

Posted in Programming

Wordpress Multipart Posts, Inlined with jQuery: Part 1

This is the first of a multipart post. I’ll be the first to admit, after you read this, and part 2, ignoring the context and concentrating on the actually content, you’d wonder why, but it makes sense when it’s all together. So I’ve seen many multipart posts out there, do this today, tomorrow do this, and every time, in order to view them all together, you, um, can’t. You have to have multiple tabs open and read one, then read the next, flippi...


Read the full article

Comments

24 Jun 09

08:00 AM MDT

Posted in Programming

Compile LLVM on Ubuntu

I needed to compile LLVM from scratch since the llvmruby gem needs it compiled with position independent code and the repo version doesn’t seem to be, the gem whines compiling, etc, etc. The docs for LLVM don’t seem to be that great when it comes to compiling this stuff from scratch, so here’s what I did, as one big script chunk. You can probably copy and paste this, but I make no promises that it will work, only that it Works on My Machine. A...


Read the full article

Comments

22 Jun 09

10:51 AM MDT

Posted in Programming

Use Net::SSH with Amazon EC2

I’m writing up some scripts to automate some EC2 setup, and SSH is required. All the examples for Net::SSH show using just a username and password, which is all good, but the Amazon stuff requires a key file. Here’s how to do it: Net::SSH.start('my.amazon.hostname.amazonaws.com', 'user', :keys => '/path/to/keypair.pem') { |ssh| ... } According to the docs, the :keys named param takes an array of file names of private keys to use for public...


Read the full article

Comments

17 Jun 09

08:00 AM MDT

Posted in Programming

Calculating age

I found this little snippet on stackoverflow This is a strange way to do it, but if you format the date to yyyymmdd and subtract the date of birth from the current date then drop the last 4 digits you’ve got the age :) I don’t know c#, but i believe this will work in any language. 20080814 – 19800703 = 280111 drop the last 4 digits = 28 All credit goes to ScArcher2 This is just a great little snippet of code, and as an upside, dates in that fo...


Read the full article

Comments