Skip to content

Instantly share code, notes, and snippets.

View agumonkey's full-sized avatar

gum agumonkey

  • NONE
  • Dark side of the moon @ ['tkf8-2-1', 'ay21-3', '3263-827']
View GitHub Profile

I like LYAH as a reference and cheat-sheet but I found it a little slow for learning Haskell.

Here's my recommended order for just learning Haskell:

http://yannesposito.com/Scratch/en/blog/Haskell-the-Hard-Way/ 80% completion here is fine if you feel your attention waning, the next thing will address hammering in things like functors and monads via typeclasses.

https://github.com/NICTA/course/ this will hammer in the lessons in a very direct form by forcing you to confront the challenges and lessons learned by the creators and community of Haskell itself. Doing the exercises here is critical for being fluent.

Real World Haskell is available online. I recommend it as a reference only.

@agumonkey
agumonkey / journald.conf
Created March 23, 2014 21:27
push events log to a tty
ForwardToConsole=yes
TTYPath=/dev/tty12
MaxLevelConsole=info
@agumonkey
agumonkey / pharen_lexical_scope_bug.phn
Created March 24, 2014 21:32
compiler seems to lift inner HOF too early, binding with top level values
(fn rev (l)
"[a] -> [a]"
(fn aux (l a)
(if (empty? l)
a
(aux (rest l) (cons (first l) a))))
(aux l []))
;; (rev [])
;; (rev [1 2 3])
@agumonkey
agumonkey / python_sh_itemgetter_snippet.py
Created June 1, 2014 14:27
python sh itemgetter snippet
import sh
from operator import itemgetter
ids = [0,3,4,-1]
fns = [fn.strip().split(' ') for fn in sh.ls("-lahrtX",_iter=True)][1:]
[itemgetter(*ids)(fn) for fn in fns]
@agumonkey
agumonkey / gist:807a6b1fe188104d6460
Created June 2, 2014 20:09
ifconfig.me json data
import json
import requests
json.decoder.JSONDecoder().decode(requests.get('http://ifconfig.me/all.json').content.decode('utf-8'))
@agumonkey
agumonkey / insert-xsel.el
Created June 2, 2014 21:05
Little elisp wrapper around `xsel`
(defun insert-xsel ()
(interactive)
(with-current-buffer (current-buffer)
;; (insert (shell-command-to-string "xsel")))) ;; also hangs some times
(insert (shell-command-to-string "xsel -o -t 10 -p"))))
@agumonkey
agumonkey / templicate.el
Created June 30, 2014 13:53
virtual pseudo code for a simple differential line duplicator, turning some parts of the previous line as placeholders in a temporary yasnippet
(defun templicate ()
"duplicate the current line as a temporary
snippet to be filled on the fly.
"
(interactive)
(let ((line (current-line))
(placeholders (select-many "word:"))
(template (mk-yasnippet-from-string line placeholders)))
(progn
(open-line)
@agumonkey
agumonkey / python-mode-newdef.el
Created August 3, 2014 13:12
Fast function addition: Jumps below the current defun, from anywhere inside it, at the same indentation level
(defun python/find-relative-indentation ()
"find the previous defun indent level"
(with-current-buffer (current-buffer)
(save-excursion
(let* ((previous-def (progn (search-backward "def ") (point)))
(previous-bol (progn (beginning-of-line) (point)))
(indent (- previous-def previous-bol)))
indent))))
;; def foo():
@agumonkey
agumonkey / functor.el
Created August 10, 2014 07:31
Everything is a function ? even structs and types ?
(setq lexical-binding t)
(defun make-struct (fields)
(lambda (values)
(let ((map (-zip fields values)))
(lambda (field)
(assoc field map)))))
;;; generic
(setq s (make-struct '(:a :b :c)))
@agumonkey
agumonkey / config.py
Created September 27, 2014 10:03
attempt to recreate config [key = value] file loader with comments and more
def load(c):
d = {}
with open(c) as cnf:
for l in cnf.readlines():
if not l.startswith('#'):
k,v = l.split('=',1)
d[k] = v.strip()
else:
if l.startswith('##'):
instr = l[2:]