Malicious enjoyment derived from observing someone else’s misfortune
 

Tag Archives: rails

Thumper: a photo and YouTube aggregator for Rails

I made a project today. It’s called Thumper. All you have to do is post a special string to a url, and it does all the work. Catalog those cool images and videos. It’s available in https://modzer0.cs.uaf.edu/repos/hank/code/ruby/thumper It’s very simple to use. You run it anywhere, and make requests like this: # Makes a new YouTube video curl -i -X POST -d “video[code]=IsyWlcQAy-Q" http://server/youtube/new curl -i -X POST -d "photo[url]=http://www.ipnlighting.com/images/wasted.jpg" http://server/pics/new Voila! Thumper lives!

Stupid Open-URI problem

URI::InvalidURIError (bad URI(is not URI?): ‘http://www.ipnlighting.com/images/wasted.jpg’): /usr/local//lib/ruby/1.8/uri/common.rb:432:in `split’ /usr/local//lib/ruby/1.8/uri/common.rb:481:in `parse’ #… I couldn’t get it to work! Wait… Parameters: {“photo”=>{“url”=>”‘http://www.ipnlighting.com/images/wasted.jpg’”}, “action”=>”new”, “controller”=>”photos”} Of Course! curl -i -X POST -d \ “photo[url]=http://www.ipnlighting.com/images/wasted.jpg” \ http://localhost:3000/photos/new All better!

Cheating on ERB with HAML

Flash!! Zoom!! !!! %html %head %link{ :rel => “shortcut icon”, :href => “/favicon.ico”, :type => “image/x-icon”}/ %title= “Wallpaper Love Factory :: “+controller.controller_name.capitalize = stylesheet_link_tag ‘wallpaper’ %body .header#header = render :partial => ‘layouts/header’ .menu#menu= render :partial => ‘layouts/menu’ .content#content= yield It’s so easy! Anyone can do it. HAML is sweeping the rails world like a wildfire of chicken, and everyone wants the biggest piece. I decided to try it last night on my new wallpaper site, and found that it’s extremely [...]

XKCD Typo Sidebar

I made a sweet sidebar today that I’ve been wanting to make for a long time. I usually forget to head over to XKCD, so I wanted a way to have the newest images staring me in the face all the time. Now, thanks to the magic of RSS, they’re right in front of me. They are lightboxed, so I have the newest comics and their captions available to me without even leaving my own site. How homey. To get [...]

Graticule: Geocoding on Rails

I’ve been using Graticule for geocoding in a Rails project at work, and I decided I needed to make some changes. So, I turned the Graticule gem into a plugin. It’s available here: ./script/plugin install -x https://modzer0.cs.uaf.edu/repos/hank/code/ruby/graticule_plugin It’s as simple as that. Then just jam this into your environment and change it accordingly: GEOCODERS = [ Graticule.service(:google).new('google_key'), Graticule.service(:yahoo).new('yahoo_key'), Graticule::GeocoderUsGeocoder.new, Graticule::MetaCartaGeocoder.new ] Then you can just perform looping on GEOCODERS to do your queries on every site. There’s also some other [...]

Route Resource Magic Pants

Apparently, you can make things like users_path and groups_path work if you do this in routes: map.resources :group Finally. Now I can continue adding groups to Beast.

Ultimate Hosting Review: Site5

So, I am currently hosting this blog on Site5’s $5 Deal. I paid $120 for 2 years of hosting with 55GB HD Space and 5TB/month transfer allowance. So far, I am very happy with it, and I’m going to share some gory details with you. The deal on the site looked to good to be true, and I thought it might be. So far, I haven’t noticed any deviances or misconceptions at all though. Here’s what it looks like when [...]

Google Adsense Typo Sidebar

Well, I made the transition to Site5 Hosting today. They have an amazing deal – $5/month for 2 years gets you 5 TB/month transfer and 55 GB HD Space. It’s a very Rails-Friendly environment, too! I got Typo up and running today which was transfered from the college webserver it’s been on for a year. They give you shell access, unlimited databases…it’s insane. And I also transferred my domain there – $8.88/year is a little expensive, but that’s OK. They [...]

Ruby on Rails GDM Theme

For all you Rails freaks out there, I modded the default Ubuntu Dapper GDM theme to match the Ruby/Rails leetness. Check it out with SVN: # Get sudo svn co http://modzer0.cs.uaf.edu/repos/hank/env/Rails \ /usr/share/gdm/themes/Rails # Run! sudo gdmsetup Pretty cool, eh? Screenshots soon. Update (1/2/07): Added welcome message support.

Extending RedCloth

I wanted to put emoticons into Textile for Beast, but to do it, I needed to use very few lines of code since there is a 500LOC limit on Beast. After a long time debugging, here’s what I came up with: First, I made a new method in the RedCloth namespace. class RedCloth def refs_smiley(text) text.gsub!(/(\s)~(:P|:D|:O|:o|:S|:\||;\)|:’\(|:\)|:\()/) do |m| bef,ma = $~[1..2] filename = ActionController::AbstractRequest.relative_url_root+”/images/emoticons/”+(ma.split(//).collect{|l|l[0]}.join(‘_’))+”.png” “#{bef}<img src=’#{filename}’ title=’#{ma}’ class=’smiley’ />” end end end All I’m doing here is some nifty gsubbing [...]