Skip to content

Instantly share code, notes, and snippets.

View yrgoldteeth's full-sized avatar

Nicholas Fine yrgoldteeth

View GitHub Profile
var i = 0;
var slide;
function SlideShow() {
Effect.Fade($( slide[i] ), { duration:5 });
i++;
if (i == slide.length) i = 0;
Effect.Appear($( slide[i] ), { duration:5, afterFinish: function () { SlideShow(); } });
}
$(document).ready(function() {
var $tabs = $('#tabs').tabs();
$('.next').click(function() { var $tabs = $('#tabs').tabs();
var selected = $tabs.tabs('option', 'selected');
$tabs.tabs('select', selected + 1); return false;
})
$('.previous').click(function() { var $tabs = $('#tabs').tabs();
var selected = $tabs.tabs('option', 'selected');
$tabs.tabs('select', selected - 1);
return false;
#so very stolen from http://gist.github.com/145676
require 'open-uri'
def download(from, to = from.split("/").last)
#run "curl -s -L #{from} > #{to}"
file to, open(from).read
rescue
puts "Can't get #{from} - Internet down?"
exit!
end
# Nicholas Fine
# nicholas.fine@gmail.com
# This is just my general collection of useful methods, algorithms, etc.
##############################################################################
# Get the date for the nth weekday of a given month and year. Call date_for_nth_weekday({2009,3,:monday,3}) to
# get the third monday of april in 2009
def date_for_nth_weekday(h={:year, :month, :week_day, :nth})
days_of_week = {:sunday => 0, :monday => 1, :tuesday => 2, :wednesday => 3, :thursday => 4, :friday => 5, :saturday => 6}
twd = days_of_week[h[:week_day]]
[2010-04-14 22:46:09 -0400] Getting customer..
[2010-04-14 22:46:09 -0400] Getting products..
not matched 5102
[2010-04-14 22:46:23 -0400] Getting customer..
[2010-04-14 22:46:23 -0400] Getting products..
not matched 5103
[2010-04-14 22:46:36 -0400] Getting customer..
[2010-04-14 22:46:36 -0400] Getting products..
not matched 5104
[2010-04-14 22:46:49 -0400] Getting customer..
require 'rubygems'
require 'active_support'
require 'open-uri'
class GoogleWeather
WEATHER_URL = "http://www.google.com/ig/api?weather=35205"
attr_accessor :weather_information
def initialize(url=WEATHER_URL)
@yrgoldteeth
yrgoldteeth / gist:397368
Created May 11, 2010 14:25
Adds a string to a csv file with category fed from a bash function that wraps git commit -m
require 'rubygems'
require 'active_support'
require 'ruby-debug'
class WorkorderCreator
attr_accessor :category, :message, :data_file
def initialize(args=[])
@data_file = File.join("/home/ndfine/code/misc/work_order", "#{Time.now.strftime('%Y_%m_%d')}_work_orders.csv")
@category = args.last
@yrgoldteeth
yrgoldteeth / gist:397369
Created May 11, 2010 14:26
Export workorders created from git commit messages from csv file. Takes optional number argument to go back n days.
require 'rubygems'
require 'active_support'
require 'excelsior'
class WorkorderList
attr_accessor :data_file, :data, :workorders
def initialize(day=Time.now)
@data_file = File.join('/home/ndfine/code/misc/work_order', "#{day.strftime('%Y_%m_%d')}_work_orders.csv")
gitcommit () { git commit -m"$1"; ruby /home/ndfine/code/misc/workorder_creator.rb "$1" "$2"; }
workorders () { ruby /home/ndfine/code/misc/workorder_list.rb $1; }
addworkorder () { ruby /home/ndfine/code/misc/workorder_creator.rb "$1" "$2"; }
class SyncPlsTellerIds
attr_reader :updated, :not_found
def initialize
@updated = []
@not_found = []
end
def run
tellers_to_update.each do |t|