Skip to content

Instantly share code, notes, and snippets.

View mrchrisadams's full-sized avatar

Chris Adams mrchrisadams

View GitHub Profile
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
#!/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
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
>> 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
@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
#!/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))}
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