Skip to content

Instantly share code, notes, and snippets.

@miletbaker
miletbaker / map_tile.rb
Created October 9, 2011 19:11
Ruby script to scale and crop an image into overlay or map tiles for use with Google Maps API, Javascript for display custom map tiles below.
#! /usr/bin/ruby -w
require 'rubygems'
require 'rmagick'
require 'fileutils'
include Magick
ARGV.each do |file|
puts "Processing #{file}"
@durran
durran / simple_form.rb
Created September 16, 2011 11:25
Mongoid with simple form.
module SimpleForm
class FormBuilder
alias _find_association_reflectio find_association_reflection
def find_association_reflection(association) #:nodoc:
if reflection = _find_association_reflectio(association)
ActiveModelMetadataProxy.new reflection
end
end
@mxriverlynn
mxriverlynn / 1-model-workaround.rb
Created June 13, 2011 20:47
Code For: Partially Solving The Date Parsing Defficiency Of Rails 3 And Mongoid
class SomeModel
include Mongoid::Document
field :date, :type => Date
validates_presence_of :date
def date=(value)
begin
date_parsed = value.to_date
write_attribute :date, date_parsed
@rharjes
rharjes / FbConsole.rb
Created June 8, 2011 18:40
Simplified Facebook interactions/navigation via Ruby/Mechanize.
#####################################################################
# Simplified Facebook interactions/navigation via Ruby/Mechanize. #
# Author: Robbie Harjes #
# Date: 6/8/2011 #
# Notes: Not liable for misuse; free for non-commercial projects.#
# This notice must remain intact if you use this code. #
#####################################################################