Skip to content

Instantly share code, notes, and snippets.

@rsslldnphy
rsslldnphy / tweet.json
Created August 5, 2013 12:40
Example Tweet JSON
{
"created_at": "Sun Aug 04 20:08:59 +0000 2013",
"id": 364115772693430300,
"id_str": "364115772693430272",
"text": "@jamescotterill Congratulations, Tintin!",
"source": "<a href=\"http://tapbots.com/software/tweetbot/mac\" rel=\"nofollow\">Tweetbot for Mac</a>",
"truncated": false,
"in_reply_to_status_id": 364104514800222200,
"in_reply_to_status_id_str": "364104514800222208",
"in_reply_to_user_id": 14436601,
module Daodalus
module EventMachineSupport
def collection
db.collection(collection_name)
end
end
end
@rsslldnphy
rsslldnphy / Gemfile
Created September 3, 2013 11:11
Headless testing in teamcity
## add the following to your Gemfile
gem 'headless'
@rsslldnphy
rsslldnphy / triples.rb
Created September 4, 2013 12:12
Triples Ruby stuff
require 'faraday'
require 'yajl'
require 'id'
class Subject
include Id::Model
field :type
field :value
@rsslldnphy
rsslldnphy / nutch_setup.sh
Created September 18, 2013 08:58
Sor and nutch setup
# set up java
sudo apt-get install openjdk-7-jdk
echo "export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64" >> ~/.bashrc
# get nutch 1.7
curl "http://mirror.ox.ac.uk/sites/rsync.apache.org/nutch/1.7/apache-nutch-1.7-bin.tar.gz" > nutch.tar.gz
tar zxvf nutch.tar.gz
cd ~/apache-nutch-1.7
# add some urls to crawl (optionally use seeds.txt in this gist)
@rsslldnphy
rsslldnphy / model.rb
Created October 17, 2013 11:48
Looong methods! And code in the initializer!
module Id::Model
def initialize(data = {})
@data = data.reduce({}) do |acc, (k, v)|
field = fields[k.to_sym]
v ||= field.default!
v = field.type.new(v) if field.type.is_a?(Id::Model) && !v.nil?
acc.merge(k.to_s => Id::Hashifier.enhash(v))
end
end
@rsslldnphy
rsslldnphy / dna.hs
Created November 15, 2013 17:41
Haskell RNA transcription!
-- Short version to show the power of Haskell :-)
module DNA(toRNA) where
toRNA = map convert where
convert 'T' = 'U'
convert n = n
-- Long version with a bunch of cool stuff that makes me happy
@rsslldnphy
rsslldnphy / Bob.pm
Created December 10, 2013 10:07
Bob in Perl5
use strict;
use warnings;
{
package Bob;
sub hey {
if (&_shouting) {
"Woah, chill out!"
} elsif (&_question) {
@rsslldnphy
rsslldnphy / request.clj
Created December 30, 2013 23:16
Functional HTTP request
(ns request)
(defn request [] {})
(defn body [] {})
(defn file [] {})
(defn set-url
[request url]
(assoc request :url url))
@rsslldnphy
rsslldnphy / xox_spec.rb
Created January 9, 2014 13:52
noughts and crosses
class Board
def squares
@squares ||= [[:_, :_, :_],[:_, :_, :_],[:_, :_, :_]]
end
def square(x, y)
squares[y][x]
end
def place(counter, x, y)