Skip to content

Instantly share code, notes, and snippets.

View yrgoldteeth's full-sized avatar

Nicholas Fine yrgoldteeth

View GitHub Profile
# **Whereabouts** is a Rails plugin that generates a polymorphic, inheritable
# Address model. Install it as a Rails plugin (Rails 3.x+ required)
#
# rails plugin install http://github.com/yrgoldteeth/whereabouts.git
#
# The most simple use case creates a has_one relationship with
# a generic Address:
#
# class Foo < ActiveRecord::Base
# has_whereabouts
def expensive_method
@expensive_method_result ||= expensive_thing
end
@yrgoldteeth
yrgoldteeth / instapaper_userstyle.css
Created September 3, 2011 05:58
My userstyle for the instapaper site.
body {
background: #000000 !important;
color: #f4f4f4 !important;
font-family: helvetica, sans-serif !important;
}
a:link {
color: #61BFC1 !important;
font-weight: normal !important;
text-decoration:none !important;
}
Array.max = (array) ->
Math.max.apply Math, array
Array.min = (array) ->
Math.min.apply Math, array

Assumptions

  • Ruby 1.9.2
  • Rails 3.1.0
  • Ubuntu Server 11.04

Server Setup

apt-get update

apt-get upgrade -y

Rails Asset Path CSS

$ sed 's/url(([^(]*))/url(<%= asset_path("\1") %>)/g' styles.css > styles.css.erb

[{"x"=>1.8733333333333335,
"y"=>"1.04",
"z"=>"0.08",
"label"=>
{"color"=>"#4bb2c5",
"label"=>"2379 - Other Heavy and Civil Engineering Construction"}},
{"x"=>3.5825000000000005,
"y"=>"0.44",
"z"=>"0.13",
"label"=>

Assumptions

  • Ruby 1.9.2
  • Rails 3.1.0
  • Ubuntu Server 11.04

Server Setup

apt-get update

apt-get upgrade -y

kml:
- ["Zone 1", "~/code/alabama-beach-pool/public/zones/aiua_zone_1_2009.kml"]
- ["Zone 2", "~/code/alabama-beach-pool/public/zones/aiua_zone_2_2009.kml"]
- ["Zone 3", "~/code/alabama-beach-pool/public/zones/aiua_zone_3_2009.kml"]
- ["Zone 4", "~/code/alabama-beach-pool/public/zones/aiua_zone_4_2009.kml"]
@yrgoldteeth
yrgoldteeth / _orders.html.erb
Created November 11, 2011 03:34 — forked from gonzedge/_orders.html.erb
Rails 3.1 - will_paginate and ajax
<ul>
<% @orders.each do |order| %>
<li>
<!-- Show order stuff -->
</li>
<% end %>
</ul>
<%= will_paginate @orders %>