Skip to content

Instantly share code, notes, and snippets.

View DarrenN's full-sized avatar
🌵
(on-a vision-quest)

Darren DarrenN

🌵
(on-a vision-quest)
View GitHub Profile
@DarrenN
DarrenN / sexprs.peg
Last active December 4, 2015 00:51
PEG Sexprs
{
function getType(def, head) {
switch (head) {
case "and":
case "or":
case "not":
return "booleanOperator";
case "eq":
case "ne":
@DarrenN
DarrenN / traceroute
Created February 9, 2013 18:43
In a traceroute far far away....
traceroute to 216.81.59.173 (216.81.59.173), 64 hops max, 52 byte packets
1 10.0.1.1 (10.0.1.1) 2.586 ms 2.537 ms 2.488 ms
2 cpe-24-193-64-1.nyc.res.rr.com (24.193.64.1) 39.531 ms 40.378 ms 29.598 ms
3 tenge-0-1-0-1-nycmnyr-rtr02.nyc.rr.com (24.168.135.197) 16.053 ms 14.207 ms 12.974 ms
4 bun120.nyquny91-rtr001.nyc.rr.com (184.152.112.151) 24.183 ms 26.115 ms 21.825 ms
5 bun6-nyquny91-rtr002.nyc.rr.com (24.29.148.254) 22.984 ms 18.966 ms 17.828 ms
6 107.14.19.22 (107.14.19.22) 20.939 ms 30.737 ms 24.894 ms
7 ae-0-0.pr0.nyc20.tbone.rr.com (66.109.6.157) 20.862 ms 19.818 ms 19.913 ms
8 te7-4.ar1.nyc8.gblx.net (208.48.23.1) 22.280 ms
tengigabitethernet3-3.ar7.nyc1.gblx.net (64.213.104.193) 20.512 ms 15.321 ms
@DarrenN
DarrenN / neckbeard.coffee
Last active December 15, 2015 08:48
Little Schemin' in CoffeeScript
car = (arr) ->
arr[0]
cdr = (arr) ->
arr[1..]
# Using for loop
map = (arr, func) ->
func(r) for r in arr
@DarrenN
DarrenN / canvas.html
Created December 7, 2013 16:42
Gnarly drag/drop with ClojureScript and core.async - http://cljsfiddle.net/fiddle/DarrenN.async.delta
<div id="canvas">
<h1>Click and drag boxes</h1>
<ul>
<li class="box"></li>
<li class="box"></li>
<li class="box"></li>
</ul>
</div>
@DarrenN
DarrenN / async.cljs
Last active December 30, 2015 19:29
Using core.async to test inserting/removing a crapton of DOM nodes to make sure domina properly remove them from memory - http://cljsfiddle.net/fiddle/DarrenN.dom.test
(ns DarrenN.dom.test
(:require [cljs.core.async :refer (<! >! chan put! take! alts! timeout close! dropping-buffer sliding-buffer)]
[domina :as dom]
[domina.events :as events]
[domina.css :as css]
[hiccups.runtime :as hiccupsrt])
(:require-macros [cljs.core.async.macros :refer (go alt!)]
[hiccups.core :as hiccups]))
(defn make-style []
@DarrenN
DarrenN / buffer.cljs
Last active December 31, 2015 08:49
Buffered vector as a value - not stored in an atom
(ns DarrenN.stateless.buffer)
;; create-buffer returns a vector scoped to size. When new items are added
;; they are passed to functions in add-listeners. If the vector is at its
;; size limit then items are shifted off the front of the vector and
;; passed to the functions in destroy-listeners
;; Callbacks for adding/removing item from vector
(def destroy-listeners [(fn [i] (print (str i " removed")))])
(def add-listeners [(fn [i] (print (str i " added")))])
@DarrenN
DarrenN / core.cljs
Last active December 31, 2015 09:29
Create a queue of dom elements with core.async
(ns buffers.core
(:require
[cljs.core.async :refer (<! >! chan put! take! alts! timeout close! dropping-buffer sliding-buffer)]
[domina :as dom]
[domina.css :as css]
[domina.events :as ev]
[hiccups.runtime :as hiccupsrt])
(:require-macros
[cljs.core.async.macros :refer (go alt!)]
[hiccups.core :as hiccups]))
syntax where = function(ctx) {
const binaryOps = ["or", "and", "==", ">", "<", "-", "+", "*", "/", "."];
const dummy = #`dummy`.get(0);
function matchNext(names) {
const marker = ctx.mark();
const next = ctx.next();
ctx.reset(marker);
return !next.done && names.includes(next.value.val());
}
@DarrenN
DarrenN / js_http_code_constants.js
Last active October 27, 2016 23:56
HTTP Codes as ES6 Constants
// Success 2xx
export const HTTP_200_OK = 200;
export const HTTP_201_CREATED = 201;
export const HTTP_202_ACCEPTED = 202;
export const HTTP_203_NON_AUTHORITATIVE_INFORMATION = 203;
export const HTTP_204_NO_CONTENT = 204;
export const HTTP_205_RESET_CONTENT = 205;
export const HTTP_206_PARTIAL_CONTENT = 206;
export const HTTP_207_MULTI_STATUS = 207;
@DarrenN
DarrenN / find-node.el
Created January 7, 2017 16:16
Dynamically add your Node.js bin path to exec-path in Spacemacs
(defun dotspacemacs/user-init ()
;; Use whatever node is available
(setq node-path (mapconcat
'identity
(butlast (split-string (executable-find "node") "\\/")) "/"))
(add-to-list 'exec-path node-path t))