Skip to content

Instantly share code, notes, and snippets.

@cronin101
cronin101 / config.ru
Last active August 29, 2015 14:20
Playing with transfer_encoding: chunked
require './data_source'
require './stream_observer'
require './streaming_app'
source = DataSource.new
app = StreamingApp.new
app.settings.set :stream_observer_factory,
-> type { StreamObserver.new(source, type) }
@cronin101
cronin101 / the_button.rb
Created April 11, 2015 22:49
/r/thebutton Naration
require 'faye/websocket'
require 'eventmachine'
require 'json'
EM.run do
ws = Faye::WebSocket::Client.new('wss://wss.redditmedia.com/thebutton?h=e71fa51d78d282393f403bdbd5d38ca6a69a9618&e=1428873519')
last_time = 60
ws.on :message do |event|
@cronin101
cronin101 / FishBush.hs
Last active August 29, 2015 14:18 — forked from AngusP/FishBush.hs
FishBuush is a monoid under the "shouting something" operator with a unit value of "no fishes".
import Control.Arrow
import Control.Monad
nToFishBuush :: (Show a, Integral a) => a -> String
nToFishBuush n = case ((`rem` 3) &&& (`rem` 5)) n of
(0, 0) -> "FISSSSSHBUSSSHH!"
(0, _) -> "fissshhhhhh"
(_, 0) -> "bUUUUUsh"
_ -> show n
@cronin101
cronin101 / RPN.hs
Last active August 29, 2015 14:17
Reverse Polish Notation calculator
module RPN where
import Data.List
calc :: (Read a, Fractional a) => String -> a
calc = head . foldl processToken [] . words
where
processToken stack@(x:x':xs) token = case token of "/" -> (x' / x):xs
"*" -> (x' * x):xs
"+" -> (x' + x):xs
"-" -> (x' - x):xs
@cronin101
cronin101 / ingredient_parser.rb
Last active August 29, 2015 14:10
Experiment: Normalising an ingredient list
require 'engtagger'
# Normalises a line from an ingredient list
module IngredientParser
module_function
def parse(line)
tagger = EngTagger.new
tagged = tagger.add_tags(line)
@cronin101
cronin101 / 99hp.fsx
Last active August 29, 2015 14:06
"99 Haskell problems" in F#
(* Problem 1: The last element of a list *)
let problem_one =
let rec last = function
| head :: [] -> head
| head :: tail -> last tail
| _ -> failwith "Empty List"
last;;
assert ((problem_one [1]) = 1 );;
assert ((problem_one [1..10]) = 10);;
@cronin101
cronin101 / keybase.md
Created May 13, 2014 12:05
Keybase proof

Keybase proof

I hereby claim:

  • I am cronin101 on github.
  • I am cronin (https://keybase.io/cronin) on keybase.
  • I have a public key whose fingerprint is F8EA 6307 E547 60ED 92D9 3DCF 0E15 CCA2 087A 76E1

To claim this, I am signing this object:

@cronin101
cronin101 / hints.md
Last active August 29, 2015 13:57
Hints possibly required for user evaluation task.

##Initiating a RubiCL computation pipeline To start a pipeline, annotate the dataset with the corresponding C-type. This is done using the square bracket notation shown below. All questions in the evaluation will use integers.

# Array support
big_array_of_numbers = [1, 2, 3, 4]
big_array_of_numbers[Int].further.method.calls.go.here
@cronin101
cronin101 / rspec.txt
Created March 23, 2014 20:01
rpsec --format documentation
Hadope
Showcasing features
can complete an Integer pipeline computation
can complete a Double pipeline computation
returns the correct result
can #zip and #braid
Top level namespace
is defined
Devices
@cronin101
cronin101 / codez.rb
Last active August 29, 2015 13:57
yum, code generation.
main ⭔ (1..100)[Int].map { |x| x + 10 }.map { |y| y * y}.filter { |x| x.even? }.filter { |y| y < 200 }[Fixnum]
#[2014-03-23 14:44:27 +0000] Simplify!: Simplified from [["x = x >> 1", "x = x + 10", "x = x * x"], ["x = x + 10"], ["x = x * x"], ["((x % 2 == 0)) && (x < 200)"], ["x < 200"], ["x = (x << 1) | 0x01"]], to [["x = x >> 1", "x = x + 10", "x = x * x", "?{((x % 2 == 0)) && (x < 200)}?", "x = (x << 1) | 0x01"]].
#[2014-03-23 14:44:27 +0000] Executing filter kernel:
# __kernel void hadopemappingfilter7(__global int *data_array, __global int *presence_array) {
# int x;
# int global_id = get_global_id(0);
# x = data_array[global_id];
#
# x = x >> 1;
# x = x + 10;