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 'csv' | |
codes = [] | |
CSV.open("codes.csv", 'r') do |row| | |
# put the contents of the first column in each row in codes.csv, | |
# into the second column of each of codes | |
codes[row[1].to_i] = row[0] | |
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
#!/usr/bin/ruby | |
require 'rubygems' | |
require 'net/http' | |
require 'rio' | |
body = Net::HTTP.get 'minneapolisfuckingrocks.blogspot.com', '/2009/01/diplo-remix-collection.html' | |
links = body.scan(/http:\/\/[a-zA-Z0-9_\.\/]*mp3{1}/) | |
links.each {|link| rio(link) > rio(File.basename(link))} |
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
sudo aptitude search mysql | grep "^i" | |
i libdbd-mysql-perl - A Perl5 database interface to the MySQL da | |
i libmysqlclient15-dev - MySQL database development files | |
i libmysqlclient15off - MySQL database client library | |
i mysql-client-5.0 - MySQL database client binaries | |
i mysql-common - MySQL database common files | |
i mysql-server - MySQL database server (metapackage dependi | |
i mysql-server-5.0 - MySQL database server binaries | |
i php5-mysql - MySQL module for php5 |
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
>> e = DateTime.strptime('2009-05-07T01:33:23+01:00') | |
=> Thu, 07 May 2009 01:33:23 0100 | |
>> f = DateTime.strptime('2009-05-06T23:33:23+01:00') | |
=> Wed, 06 May 2009 23:33:23 0100 | |
>> e - f | |
=> Rational1, 12 | |
>> a = Time.now | |
=> Thu May 07 10:25:53 -0400 2009 | |
>> b = Time.now |
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 "nokogiri" | |
require "open-uri" | |
# last week, I started writing this code to parse data from search.ucas.com | |
# to help some of the people going to Young Rewired State. It looks like I'm | |
# not going to be able to go to YRS as I'm busy with academic work. I'd | |
# really appreciate it if someone could help them out. | |
# you don't have to use Ruby - it's just my hack language of choice. this |
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 | |
# Script to import tumblr posts into local markdown posts ready to be consumed by Jekyll. | |
# Inspired by New Bamboo's post http://blog.new-bamboo.co.uk/2009/2/20/migrating-from-mephisto-to-jekyll | |
require 'rubygems' | |
require 'open-uri' | |
require 'nokogiri' | |
# Configuration |
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
def just_one_kind_of_response?(item, controller) | |
case controller | |
when 'suggestions', 'actions' | |
return item.comments.blank? || item.actions.blank? | |
when 'thoughts' | |
return item.comments.blank? || item.suggestions.blank? | |
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
#!/usr/bin/env ruby | |
unless ARGV[0] | |
puts 'Usage: newpost "the post title"' | |
exit(-1) | |
end | |
# set the date for the entry, where the jekyll blog is and process the title to give a filename: | |
date_prefix = Time.now.strftime("%Y-%m-%d") | |
postname = ARGV[0].strip.downcase.gsub(/ /, '-') |
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
:groups => {:app => {:gid => 1003}, | |
:site => {:gid => 3001}, | |
:support => {:gid => 3002} | |
}, | |
:users => { | |
:app => { | |
:password => "$1$39393939393939393.", | |
:comment => "App User", | |
:uid => 1000, | |
:groups => [: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
#!/usr/bin/env ruby | |
require Dir | |
unless ARGV[0] | |
puts 'Usage: newpost "the post title"' | |
exit(-1) | |
end | |
blog_root = "/Users/chrisadams/Code/notes" |
OlderNewer