This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Author Jason Amster | |
# 11/18/08 | |
app_name = ARGV[0] | |
if ARGV.length > 0 | |
puts "Creating new Rails/Bort App #{app_name}" | |
else | |
puts "Please name your Bort app" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# = Top 100 Greatest Movie Characters Scraper | |
# This program just scrapes the empire online 100 | |
# greatest movie characters web site (http://www.empireonline.com/100-greatest-movie-characters/) | |
# and generates a simple page to display all the | |
# characters on one page so you don't have to go | |
# clicking through 100 pages | |
# | |
# This was just built b/c I'd rather learn something new | |
# during the time it took me to view all 100 characters | |
# and still get to see who they are. I'm too lazy to click |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'httparty' | |
class DataFetcher | |
include HTTParty | |
format :xml | |
base_uri "some.domain.com/api" | |
def fetch_data | |
get('/method', :query => {:param1 => 'hello', :param2 => 'world'}) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This code just takes multiparamter inputs from a form and strings them together to | |
# create dash separated date string. The purpose behind this is because sometimes if | |
# a user doesn't fill in all the date drop downs in a form, you might get an invalid date | |
# The folowing code was repurposed from ActiveRecord::Base from a few of the mutliparamter | |
# assignment methods | |
module ConverDateParamsToString | |
def convert_date_params_to_string!(params, date_attr_name) | |
date_params = params.reject {| key, value | !(key =~ /^#{date_attr_name}/) } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Deomontrates (very simply) how Active Record handles multiparameter assignments | |
require "rubygems" | |
require "activesupport" | |
require "activerecord" | |
this_hash = { | |
"date(3i)" => "20", | |
"date(2i)" => "1", | |
"date(1i)" => "2003" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "activesupport" | |
class Person | |
attr_accessor :name, :age | |
def initialize(name, age) | |
@name=name | |
@age=age | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Date | |
def self.days_between(start, finish) | |
(finish - start).to_i | |
end | |
def self.weeks_between(start, finish) | |
days_between(start, finish) / 7 | |
end | |
def self.months_between(start, finish) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# EXTRACTED FROM THIS THREAD: | |
# http://rails.lighthouseapp.com/projects/8994/tickets/879-finding-the-days-weeks-months-years-between-two-dates | |
require "rubygems" | |
require "activesupport" | |
#activesupport is necessary for Date.parse (I think) | |
class Date | |
def self.days_between(start, finish) | |
(finish - start).to_i | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
while 1 | |
unixtime = Time.new.strftime('%s') | |
if Integer(unixtime) > 1234567890 | |
puts "HOORAAAYYYY Unix Time > 1234567890 - #{unixtime}" | |
else | |
puts "Booooo Unix Time not yet #{unixtime}" | |
end | |
sleep 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# bash completion support for core Git. | |
# | |
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]> | |
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/). | |
# Distributed under the GNU General Public License, version 2.0. | |
# | |
# The contained completion routines provide support for completing: | |
# | |
# *) local and remote branch names |
OlderNewer