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
@agumonkey
agumonkey / regenerate-elpa-autoloads.el
Created October 28, 2014 12:01
Trying to batch rebuild elpa packages autoloads
(require 'dash)
(setq lexical-binding t)
(defun is-dot-p (dir)
(or (equal dir ".")
(equal dir "..")))
(defun get-package-from-dirname (dn)
(mapconcat #'identity (-butlast (split-string dn "-")) "-"))
@agumonkey
agumonkey / kurl
Created November 17, 2014 13:45
curl wrapper to only pipe text mime type to stdout, the rest to the filesystem
#!/usr/bin/env sh
case $(curl -sLI $1 | grep -i content-type) in
*text*) echo "curl $1"
;;
*) echo "curl $1 > $(basename $1)"
;;
esac
@agumonkey
agumonkey / pick.clj
Created November 25, 2014 16:50
clojure implementation of javascript pick operator on maps
(defn pick [m & ks]
"map ks vs -> [ks'] -> map ks' vs'"
(reduce (fn [a k] (assoc a k (m k))) {} ks))
;;; test
(let [m {:trace-redirects ["http://html5test.com"],
:request-time 126,
:status 200,
:headers {"content-encoding" "gzip",
@agumonkey
agumonkey / tmp-bang.el
Created December 4, 2014 12:58
A function to generate new temporary buffers with suffixed names. Needed to have an `-iterate-while` combinator. Leveraging dash.el many times.
(defun -iterate-while (fn pred &optional limit)
(let ((limit (or limit 128))
(r (funcall fn)))
(if (or (not (funcall pred r)) (= 0 limit))
r
(-iterate-while fn pred (1- limit)))))
;; (funcall (-flip #'<) 2 1)
;; (funcall (-partial (-flip #'<) 10) 0)
@agumonkey
agumonkey / toggle-list-orientation.el
Created March 21, 2015 07:01
Reupload and ~patch of Kragen toggle-list-orientation code
;; Like everything else posted to kragen-hacks without any notice to the
;; contrary, this program is in the public domain; I abandon any
;; copyright in it.
;;; Toggling of argument lists between horizontal and vertical.
;; For example, turn this: memset(bigstring, '\xe3', bigstringsize-1);
;; into this: memset(bigstring,
;; '\xe3',
;; bigstringsize-1);
;; or vice versa.
@agumonkey
agumonkey / pype_tests.py
Created May 4, 2015 12:42
python3 shell pipe emulator
# @>>> Pipe() | ['echo', 'foo bar baz'] | ['grep', 'a'] | None
# b'foo bar baz\n'
# @>>> Pipe() | ['echo', 'foo\nbar\nbaz'] | ['grep', 'a'] | None
# b'bar\nbaz\n'
@agumonkey
agumonkey / generator_unpacking.py
Created May 6, 2015 16:10
generator unpacking for python ?
def coca_cola():
while True:
yield True
head, *tail = coca_cola()
>>> head = True, tail = <generator....>
@agumonkey
agumonkey / syntax_helps_thinking.js
Created May 12, 2015 18:39
Syntax matters, writing things in coffeescript helped trying and seeing things. You can write semantically identical code but it takes a little longer, is a little less readable and easy to change.
// CoffeeScript
// from = (l) => (v) => l.indexOf(v) > -1
// prj = (o, ks) =>
// oks = Object.keys o
// common = oks.filter(from ks)
// common.reduce ((m, k) => m[k]=o[k]; m), {}
// o = a:1, b:2, c:3
// ls = [
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
#main{
padding:4px;
cursor: pointer;
@agumonkey
agumonkey / SassMeister-input-HTML.haml
Last active August 29, 2015 14:21
Generated by SassMeister.com.
#div(class='gui',id='s') @@@
#h1(id='t') #
#div(class='gui') !!!
.gui#s @@@
%h1#t #
.gui#u !!!