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
(defun filter-char (f) (car f))
(defun filter-fn (f) (cdr f))
(mapcar (lambda (f) (cons (char-to-string (filter-char f)) (filter-fn f))) eshell-modifier-alist)
;; ->
;; (("E" function (lambda (lst) (mapcar (function (lambda (str) (eshell-stringify (car (eshell-parse-argument str))))) lst)))
;; ("L" function (lambda (lst) (mapcar (quote downcase) lst)))
;; ("U" function (lambda (lst) (mapcar (quote upcase) lst)))
;; ("C" function (lambda (lst) (mapcar (quote capitalize) lst)))
;; ("h" function (lambda (lst) (mapcar (quote file-name-directory) lst)))
@agumonkey
agumonkey / parscope.el
Last active December 19, 2015 01:29 — forked from nickpascucci/parscope.el
added missing (provide ...), discovery/debug, wip
;;; parscope.el --- Minor mode for showing the current scope in Lisp-like languages.
;; Copyright (C) 2013 Nick Pascucci
;; Author: Nick Pascucci <npascut1@gmail.com>
;; Created: 22 Jun 2013
;; Keywords: tools
;; Version: 0.1.0
;; URL: https://gist.github.com/nickpascucci/5842987
(defvar versions '("2.2" "2.0.4.1" "3.4.5.1" "4.3.2" "0.4.1-b" "2.2.3" "4.2.3" "1.0.4" "0.1a" "1.9.3" "3.1.1" "2.5.5" "2.2.6"))
(defun parse-version (v)
(mapcar #'string-to-int (split-string (replace-regexp-in-string "[^[:digit:]]" " " v) " ")))
(defun take-until (l p)
(if (or (null l)
(funcall p (car l)))
'()
(cons (car l) (take-until (cdr l) p))))

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)