Skip to content

Instantly share code, notes, and snippets.

let random_object = System.Random()
let filelines filename = System.IO.File.ReadAllLines(__SOURCE_DIRECTORY__ + "/" + filename)
let get_random_line file = random_object.Next(0, Seq.length(file))
let get_random_word word_file = Seq.nth (get_random_line word_file) (word_file)
type words =
| Verb
| Noun
| Adjective
@mattyw
mattyw / show_cookies.py
Created May 17, 2016 09:46 — forked from cmars/show_cookies.py
Show ~/.go-cookies content without compromising authorization tokens
#!/usr/bin/env python3
import base64
import json
import os
import sys
if __name__ == '__main__':
if sys.argv[1:]:
filename = sys.argv[1]
@mattyw
mattyw / gol.hs
Created December 3, 2011 15:40 — forked from nschmoller/gol.hs
Game of life in Haskell (in 45 minutes)
zeroes 0 = []
zeroes n = [0] ++ (zeroes (n-1))
foo x y z= zipWith (+) (zipWith (+) x y) z
grid_neighbours l =
let top = map inc_neighbours ( [(zeroes (length (head l)))] ++ (take (length l) l) )
bottom = map inc_neighbours ((drop 1 l) ++ [(zeroes (length (head l)))])
current = map neighbours l
in zipWith3 foo top bottom current
;; mattyw's solution to Reverse a Sequence
;; https://4clojure.com/problem/23
(defn reverse-func [seq]
(reduce (fn [a b] (cons b a)) '() seq))
(println (= (reverse-func [1 2 3 4 5]) [5 4 3 2 1]))
@mattyw
mattyw / about.md
Created August 9, 2011 19:12 — forked from jasonrudolph/about.md
Programming Achievements: How to Level Up as a Developer