Skip to content

Instantly share code, notes, and snippets.

View yurrriq's full-sized avatar
🙉
I may be slow to respond.

Eric Bailey yurrriq

🙉
I may be slow to respond.
View GitHub Profile
@yurrriq
yurrriq / keybase.md
Last active December 24, 2015 10:54
keybase.md

Keybase proof

I hereby claim:

  • I am yurrriq on github.
  • I am yurrriq (https://keybase.io/yurrriq) on keybase.
  • I have a public key ASAFVSrtApJinkGugc0pU6mqtV4jTLiv-l5cCwdtsssraQo

To claim this, I am signing this object:

@yurrriq
yurrriq / riak-quickstart.fish
Created April 20, 2015 02:14
Riak Quickstart Commands translated to Fish
#!/usr/local/bin/fish
# Riak Quickstart: http://docs.basho.com/riak/latest/quickstart/
# Start all the nodes!
for node in dev*; eval $node/bin/riak start; end
# Ping all the nodes!
for node in dev*; eval $node/bin/riak ping; end
@yurrriq
yurrriq / README.org
Last active August 29, 2015 14:20
GitHub Languages

GitHub Languages

Prints a JSON map of the languages used in your repos, sorted by frequency in descending order.

Usage

lein run -m gh-languages # | hicat
@yurrriq
yurrriq / compojure-fix.org
Last active August 29, 2015 14:20
Getting Compojure 1.3.3 to work on Clojure 1.7.0 beta 2
@yurrriq
yurrriq / NSAttributedStringExtension.org
Last active August 29, 2015 14:20
join() for NSAttributedString

join() for NSAttributedString

String has it:

" and like ".join(["Like this", "that", "this, y'all."])
"Like this and like that and like this, y'all."
@yurrriq
yurrriq / bool.org
Last active August 29, 2015 14:22
Remember `bool`

Remember bool

Rationale

Probably due, at least in part, to my Lisp zealotry, I often find myself wanting to use if as a function.

Common solution

A common solution, is to define if'​ as follows:

if' :: Bool -> a -> a -> a
@yurrriq
yurrriq / lfe-map-issues.lfe
Last active August 29, 2015 14:26
LFE map issues
(let ((m #m(a 1 b (2 3 4) c #(a b)))
(x 'a))
;; Fail
;; (mref m x)
;; (map-get m x)
;; Work
(list
(maps:get x m)
(mref m 'b)
@yurrriq
yurrriq / zipfoldl.lfe
Last active January 3, 2017 07:17
zip two lists and foldl in one pass
;;; Notes:
;; - Doesn't check arity of `F'
;; - Like #'lists:zip/3, throws a function_clause exception
;; when given lists of unequal lengths
(defun zipfoldl
([f acc `(,ha . ,ta) `(,hb . ,tb)] (when (is_function f))
(zipfoldl f (funcall f ha hb acc) ta tb))
([f acc () ()] acc))
@yurrriq
yurrriq / restricted-lfe.org
Created August 14, 2015 07:59
Testing LFE shell in restricted mode

Testing LFE shell in restricted mode

restricted.erl

-module(restricted).
-export ([non_local_allowed/3]).
@yurrriq
yurrriq / fizzbuzz.lfe
Last active February 18, 2016 11:37
FizzBuzz in LFE
(defmodule fizzbuzz
(export (fizzbuzz 1)))
(defun fizzbuzz (n)
(lists:foreach
(lambda (x) (lfe_io:format "~p~n" `(,x)))
(lists:map #'fizz/1 (lists:seq 1 n))))
(defun fizz (n) (fizz n (rem n 3) (rem n 5)))