Skip to content

Instantly share code, notes, and snippets.

@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 / Gemfile
Created September 3, 2013 11:11
Headless testing in teamcity
## add the following to your Gemfile
gem 'headless'
module Daodalus
module EventMachineSupport
def collection
db.collection(collection_name)
end
end
end
@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,
@rsslldnphy
rsslldnphy / Main.hs
Created July 3, 2013 19:03
Improved merge sort in haskell!
module Main where
import System.Environment
main :: IO ()
main = do
args <- getArgs
mapM_ putStrLn $ sort args
sort :: (Ord a) => [a] -> [a]
@rsslldnphy
rsslldnphy / Main.hs
Created July 2, 2013 18:49
Merge sort in Haskell
module Main where
import System.Environment
main :: IO ()
main = do
args <- getArgs
mapM_ putStrLn $ sort args
sort :: (Ord a) => [a] -> [a]
@rsslldnphy
rsslldnphy / gist:5862686
Last active December 18, 2015 23:39
GAAAAAAVVVIIIIIIIIIIIINNNNNNN!!!!!!!
## Making Option[[]], Option[{}] and Option[""] return None
Looked at a certain way, it does make a kind of sense. I can see how you got the idea.
A None is itself a kind of empty collection, so why wouldn't an Option of an empty collection also be a None?
However, I think there are some important things we need to consider.
The first one is - why would you be creating an optional collection - what value would you be getting from doing so?
And what value would you be getting from empty collections being interpreted as None?
@rsslldnphy
rsslldnphy / gist:5759425
Last active December 18, 2015 09:09
bowling kata
normal score: 41 (4 then 1)
spare: 3/
strike: X
score then gutter: 4-
34X--3/34
class DCode
def initialize(assessment, user)
@assessment = assessment
@user = user
end
def code
"#{site.name[0,2]}-#{department_code}".upcase
end
@rsslldnphy
rsslldnphy / infinite.erl
Last active December 17, 2015 12:59
Basic implementation of infinite series in Erlang, take, filter and nth.
-module(infinite).
-compile(export_all).
%%% Usage
%
% Ints = infinite:stream(0, fun (X) -> X + 1 end).
%
% % Numbers from 0 to 9
% infinite:take(Ints, 10).
%