Skip to content

Instantly share code, notes, and snippets.

View mrchrisadams's full-sized avatar

Chris Adams mrchrisadams

View GitHub Profile
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
#!/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))}
@mrchrisadams
mrchrisadams / gist:78678
Created March 13, 2009 18:13 — forked from chrismear/gist:78676
my gems
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
>> 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
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
#!/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
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
@mrchrisadams
mrchrisadams / newpost.rb
Created December 17, 2009 00:47 — forked from al3x/newpost.rb
#!/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(/ /, '-')
:groups => {:app => {:gid => 1003},
:site => {:gid => 3001},
:support => {:gid => 3002}
},
:users => {
:app => {
:password => "$1$39393939393939393.",
:comment => "App User",
:uid => 1000,
:groups => [:app],
@mrchrisadams
mrchrisadams / newpost.rb
Created February 28, 2010 22:06 — forked from jrk/newpost.rb
Create a blog post in jekyll
#!/usr/bin/env ruby
require Dir
unless ARGV[0]
puts 'Usage: newpost "the post title"'
exit(-1)
end
blog_root = "/Users/chrisadams/Code/notes"