Skip to content

Instantly share code, notes, and snippets.

View seanstickle's full-sized avatar

Seán Stickle seanstickle

View GitHub Profile
#!/usr/bin/env ruby
require "rubygems"
require "hpricot"
require "open-uri"
url = "http://feeds.feedburner.com/Rubyconf2008-Confreaks"
(Hpricot(open url)/:enclosure).map {|x| x.attributes["url"]}.uniq.each do |vid|
File.exist?(vid.split("/").last) ? next : `wget #{vid}`
on run argv
tell application "Preview"
activate
open (item 1 of argv)
tell application "System Events"
tell process "Preview"
set frontmost to true
keystroke "g" using {command down, option down}
keystroke (item 2 of argv)
key code 36
def create
@ticket = Ticket.new(params[:ticket])
flash[:notice] = "Ticket created."
redirect_to(@ticket)
end
def validate
errors.add("No such category") unless self.category
end
@seanstickle
seanstickle / gist:120083
Created May 29, 2009 17:32
View to Replace MARK_SDFU
SELECT
email AS accountid,
first_design_saved_at AS dt_save,
'beta' AS timeline,
'G' AS content_type
FROM
accounts
WHERE
first_design_saved_at > DATE '2009-05-29'
AND rownum < 10
@seanstickle
seanstickle / gist:120947
Created May 31, 2009 17:35
Treetop grammar for the monadic form of the integers verb
grammar J
rule verbs
integers
end
rule integers
'i.' number {
def value
(0...number.value).map {|x| x}
@seanstickle
seanstickle / array_multiplication.rb
Created July 6, 2009 19:52
Overriding the array multiplication method to support J-style array multiplication
class Array
alias_method :old_times, :*
def *(multiplier)
if multiplier.class != Array
self.old_times multiplier
else
if self.size != multiplier.size
raise "length error"
require "rubygems"
require "net/http"
require "open-uri"
data = open("http://cdo.ncdc.noaa.gov/climatenormals/clim84/IL/IL110055.txt").map
#data = open("http://cdo.ncdc.noaa.gov/climatenormals/clim84/IL/IL112679.txt").map
metric = {}
metric[:station_coop_id] = data[4][44..49]
- @tags.each do |tag|
= link_to tag.name, tag_path(tag)
controller:
def show
begin
asset = Attachment.find(params[:id]).asset
render :text => "#{asset.path} #{asset.content_type} #{asset.original_filename}"
rescue
session_redirect
end
# Trace is a model in vendor/plugins/mylogger/lib/app/models/trace.rb
# vendor/plugins/mylogger/lib/mylogger.rb
#...
module MyLoggerImpl
def self.trace(controller_instance)
puts 'Tracing'