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 'net/imap' | |
require 'tmail' | |
require 'parsedate' | |
# NOTE: Set these values before you run the script | |
# Your gmail username | |
USERNAME = "YOUR_USERNAME" | |
# Your gmail password |
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 | |
# autoasciidoc | |
# Author: Daniel Choi [email protected] | |
# License: GPLv3 | |
# | |
# This program is a wrapper for asciidoc which watches the source text file for | |
# any changes, which automatically triggers a regeneration of the asciidoc | |
# output. | |
# | |
# Usage: |
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 | |
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
url = "http://www.yelp.com/developers/documentation/neighborhood_list" | |
doc = open(url) {|f| Hpricot(f.read)} | |
def nest(li_elem) | |
next_sibling = li_elem.next_sibling | |
if next_sibling && next_sibling.name == "ul" |
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 | |
url = ARGV.shift | |
puts "fetching #{url}" | |
target = "news.txt" # this file collects all the content | |
`lynx -dump -nomargins -nonumbers "#{url}" >> #{target}` | |
puts "done" |
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 Feed < ActiveRecord::Base | |
has_many :items, :order => "published_at desc", :dependent => :delete_all | |
has_many :feed_errors | |
# This is problematic because on update, the feed_url can be changed. It can | |
# be changed to the feed_url of another feed. TODO Figure out a way to | |
# automatically merge two feeds in this case. | |
# validates_uniqueness_of :feed_url | |
validates_presence_of :feed_url |
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
[{"assignment":{"start_date":"2010-11-15T21:05:00Z","image_file_name":null,"created_at":"2010-11-15T21:05:42Z","title":"test title","image_file_size":null,"assignee_id":1,"updated_at":"2010-11-15T21:05:42Z","max_length":"","responses_count":0,"response_asset_validations":{},"image_content_type":null,"account_id":1,"response_asset_types":["text"],"id":11,"creator_id":4,"description":"test","image_expiring_url":null,"image_updated_at":null,"end_date":"2010-11-15T21:09:00Z","state":"open"}},{"assignment":{"start_date":"2010-11-15T18:45:00Z","image_file_name":null,"created_at":"2010-11-15T18:47:36Z","title":"","image_file_size":null,"assignee_id":1,"updated_at":"2010-11-16T18:54:01Z","max_length":"","responses_count":0,"response_asset_validations":{"audio":{"length":"60"},"text":{"length":"600"},"video":{"length":"120"},"image":{"height":"","width":""}},"image_content_type":null,"account_id":1,"response_asset_types":["audio","image"],"id":10,"creator_id":4,"description":"","image_expiring_url":null,"image_updated |
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
#!/bin/bash | |
# Shows the weather forecast for Boston, MA | |
curl -s 'http://weather.noaa.gov/pub/data/forecasts/state/ma/maz007.txt' | | |
sed -n '/^TAB/,+11p; /BOSTON/,+3p' |
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
module ActsAsTaggableOn::Taggable | |
module Ownership | |
module InstanceMethods | |
def save_owned_tags | |
tagging_contexts.each do |context| | |
cached_owned_tag_list_on(context).each do |owner, tag_list| | |
orig_tag_list = tag_list | |
tag_list = ActsAsTaggableOn::Tag.find_or_create_all_with_like_by_name(tag_list.uniq) |
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
module RailsAdmin | |
class History < ActiveRecord::Base | |
set_table_name :rails_admin_histories | |
IGNORED_ATTRS = Set[:id, :created_at, :created_on, :deleted_at, :updated_at, :updated_on, :deleted_on] | |
scope :most_recent, lambda {|table| | |
where("#{retrieve_connection.quote_column_name(:table)} = ?", table).order("updated_at") | |
} |
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
#!/bin/bash | |
# This simple script sets the volume on your Mac. Put it on your PATH. | |
# | |
# Usage: macvol [volume level] | |
# | |
# Without an argument, it returns the current volume level. With an argument, | |
# it will set the volume level. The volume level may range from 0 to 100. | |
# | |
# I use this script to set the volume of my Mac Mini remotely from another |
OlderNewer