Skip to content

Instantly share code, notes, and snippets.

View jonbuda's full-sized avatar

Jon Buda jonbuda

View GitHub Profile
/*
A Revised Font Stack
from A Way Back
http://www.awayback.com/revised-font-stack/
*/
/*
@jonbuda
jonbuda / timezonefinder.rb
Created August 8, 2012 14:17
Finding a timezone with geonames.org based on geocoordinates
# offset = TimeZoneFinder.gmt_offset(some_lat, some_lng)
# timezone = ActiveSupport::TimeZone[offset]
#
# timezone = TimeZoneFinder.timezoneId(lat, lng)
# Time.zone = timezone
# Time.zone.now
#
class TimeZoneFinder
attr_accessor :result
@jonbuda
jonbuda / jquery.rake
Created February 27, 2011 22:01
Simple Rake task for Rails3 to install/update to the latest version of jQuery and the rails.js UJS driver
namespace :jquery do
desc "Installs the latest version of jQuery and the rails.js UJS jQuery Adapter"
task :install => :update do
puts "Installed jQuery and the rails.js UJS jQuery Adapter"
puts %Q{
******************************************************************************
You can update your javascript defaults in Rails3 with the following:
in application.rb, add:
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
rescue LoadError
# RVM is unavailable at this point.
raise "RVM ruby lib is currently unavailable."
# This allows you to use Passenger with RVM where each app has it's own gemset
# place the setup_load_paths.rb into your config folder of Rails app
if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
begin
rvm_path = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
rvm_lib_path = File.join(rvm_path, 'lib')
$LOAD_PATH.unshift rvm_lib_path
require 'rvm'
RVM.use_from_path! File.dirname(File.dirname(__FILE__))
DAYS_BEFORE_OPTIONS = [0,1,2,3,4,5,6,7,14,21,28]
DAYS_BEFORE_IN_WORDS = ['the day of'] + (1..6).map {|day| "#{day} days before"} + (1..4).map {|week| "#{week} weeks before"}
def self.options_for_days_before
DAYS_BEFORE_OPTIONS.map do |days|
[DAYS_BEFORE_IN_WORDS[DAYS_BEFORE_OPTIONS.index(days)], days]
end
end