Skip to content

Instantly share code, notes, and snippets.

@O-I
O-I / guardian_api_test.rb
Last active August 29, 2015 14:04
Experimenting with the Guardian Content API
require 'open-uri'
require 'dotenv'
require 'json'
require 'pry'
Dotenv.load
# Basic structure of a Guardian API request:
# BASE_URI + endpoint + queries + api-key + params
@O-I
O-I / random_sum.rb
Created July 11, 2014 16:44
Generate n unique random natural numbers whose sum is m
# Question source: http://codegolf.stackexchange.com/q/8574/12268
# Write an algorithm in any programming language you desire
# that generates n unique randomly-distributed random natural
# numbers (i.e. positive integers, no zero), sum of which is
# equal to t, where t is bigger than or equal to n*(n+1)/2.
# Example: Generate 10 unique random natural numbers, sum of which is equal to 500.
def rand_sum(size, sum)
@O-I
O-I / fizzbuzz.hs
Created July 11, 2014 16:35
FizzBuzz in Haskell
fizzbuzz :: Int -> [String]
fizzbuzz n = take n $ addNums $ zipWith (++) fizz buzz
where fizz = cycle ["", "", "Fizz"]
buzz = cycle ["", "", "", "", "Buzz"]
addNums = zipWith numOrNot $ map show [1..]
numOrNot = \ x y -> if null y then x else y
@O-I
O-I / all_about_nil.md
Last active August 29, 2015 13:57
Master of nil