Skip to content

Instantly share code, notes, and snippets.

okcoin :: Exchange
okcoin = Exchange
{ exchageName = OkCoin
, fetchTicker = fetchOkCoinTicker
}
fetchOkCoinTicker :: IO Ticker
fetchOkCoinTicker = do
r <- Wreq.asJSON =<< Wreq.get tickerUrl
let OkCoinTicker{..} = r ^. responseBody
@TGOlson
TGOlson / bubble_sort.rb
Created January 14, 2014 22:46
Ruby sorting algorithms.
def bubble_sort(list)
sorted = false
until sorted
sorted = true
(0...list.length).each do |i|
if !list[i + 1].nil? && list[i] > list[i + 1]
list[i], list[i + 1] = list[i + 1], list[i]
sorted = false
end
end
@TGOlson
TGOlson / NestedHashMap.hs
Last active May 8, 2016 03:54
Nested HashMap implementation.
module NestedHashMap where
import Control.Lens
import Data.Hashable (Hashable)
import Data.HashMap.Strict (HashMap, empty)
type NestedHashMap a b c = HashMap a (HashMap b c)
lookup
:: (Eq a, Hashable a, Eq b, Hashable b, Eq c)
@TGOlson
TGOlson / Typer.hs
Created April 9, 2016 18:22
Simple typing interface with FRP
module ReactionTest
( main
) where
import Control.Event.Handler
import Reactive.Banana
import Reactive.Banana.Frameworks
import System.IO
import System.Console.ANSI
@TGOlson
TGOlson / Dockerfile
Created March 26, 2016 02:27
GHC Cross Compiler attempt
# NOTE: Currently not working
# Gets all the way to the final ./configure step and exists with error: Unknown CPU
FROM haskell:7.10.2
RUN apt-get update
WORKDIR /opt/compiler
# Install core dependencies
@TGOlson
TGOlson / factorial.js
Last active March 22, 2016 19:30
Point free factorial kata
var R = require('ramda');
// `proxy` is a function to allow for point-free recursion in JavaScrpipt
// it takes in a function name as a string, and returns a proxy function to the original function
var factorial = R.ifElse(
R.eq(0), R.always(1),
R.converge(R.multiply, R.I, R.compose(proxy('factorial'), R.dec))
);
factorial(0);
embed.spotify.com/openspotify/?spuri=spotify:track:2IuWB214OCchhPrBK8OtIR&closedelay=5000
@TGOlson
TGOlson / import_script.sh
Created January 28, 2014 06:21
My first shell script -- isn't it cute...
echo '********************************************'
date -u
echo ' Beginning Incremental Import'
echo ' Setting PATH, GEM and RUBYLIB variables'
export PATH=/home/ckoziak/webapps/rails/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/ckoziak/bin;
export GEM_HOME=/home/ckoziak/webapps/rails/gems;
export RUBYLIB=/home/ckoziak/webapps/rails/lib;
echo ' Changing Directory to /home/ckoziak/webapps/rails/fas/'
@TGOlson
TGOlson / filters.rb
Created January 23, 2014 08:51
Meta-programming filter tool for applications. Refactor with meta-programming is shown on top, old solution on bottom.
# A filter method using meta-programming to send multiple methods to the class.
# This allows multiple ActiveRecord scopes to be stacked easily.
def self.filter(params)
max = params[:limit] || 10
methods = [:new_prices]
methods << :free if params[:free]
methods << :games if params[:games]
methods << [:limit, max]
Application.send_chain(methods)
@TGOlson
TGOlson / linked_list.rb
Last active January 4, 2016 02:29
Creating Linked Lists In Ruby
# Creating a linked list in Ruby, based on this tutorial
# http://www.commandercoriander.net/blog/2012/12/23/reversing-a-linked-list-in-ruby/
require 'benchmark'
class Entry
attr_accessor :next, :data
def initialize(data)
@next = nil