Skip to content

Instantly share code, notes, and snippets.

View aperiodic's full-sized avatar

Dan Lidral-Porter aperiodic

  • BlackBerry
  • Seattle, WA
View GitHub Profile
@aperiodic
aperiodic / transform.clj
Created December 12, 2014 19:37
transform-n
(defn transform-n
[n words]
(->> words
(partition n 1)
(reduce (fn [acc [w next-w]]
(update-in acc
[w next-w]
(fnil inc 0)))
{})))
@aperiodic
aperiodic / fizzbuzz.clj
Created November 14, 2014 19:19
Fizzbuzz Without if, when, and, or, or predicates.
(ns conditionless-fizzbuzz.core)
(defn if-divisible-by-n
[n then-fn else-fn]
(fn [x]
(let [remainder (mod x n)
chosen-fn ({0 then-fn} remainder else-fn)]
(chosen-fn x))))
(def fizzbuzzer
@aperiodic
aperiodic / gist:8358814
Created January 10, 2014 17:35
My work machine public key.
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDfXZDic/NA+CUb5poRGpSOLct5T5rNaXeRuPvGeGWZkH05c4FvvpUbCjT/OEHYJzgsJI99iCTKvusC9oG5uSKPYT/7p8m+vWvhX3wyT0zOhuyDMuGIMeWq6JYEqUhMi180Z/tn/Pl3gDXD7nGGi7lwu4BgDoHw+bpBjutXzToCqxTsagOOxVcGi+Gv/SOXGeXH/18nxThJNkffoQmGSVbeTymuxa73n5dfwl/HEfeAj/JaZ30gb+6b8+hO/JyZdgit7+FJHaw+OipuwdA/G2FzYKOfCCzbAURMJqpZy8XLiV5VxVorgKOWerYeXqw01mjWoNp7/gkIH085w4T0XUdz [email protected]
@aperiodic
aperiodic / leds.cpp
Created December 14, 2012 19:26
Driving a 5x5 RGB LED grid with 5-bit PWM using only some shift registers, a demuxer, and a timer interrupt.
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#define __spi_clock 13 // SCK - hardware SPI
#define __spi_latch 10
#define __spi_data 11 // MOSI - hardware SPI
#define __spi_data_in 12 // MISO - hardware SPI (unused)
#define __brightness_levels 32 // 0...15 above 28 is bad for ISR ( move to timer1, lower irq freq ! )
#define __max_brightness __brightness_levels-1
@aperiodic
aperiodic / mountains.clj
Created December 3, 2012 00:48
C2P0 Problem
(ns examples.mountains
(:require [c2po.core :refer [c2po]]
[c2po.geom :as geom]
[c2po.scale :as scale]
[c2po.livereload-server :refer [render!]]))
(def animals
;; episode 2: mountains
{:gelada-baboon {:pop 200000, :child-rate 0.5, :unit 15}
:walia-ibex {:pop 500, :child-rate 1, :unit 10}
@aperiodic
aperiodic / Error & Trace
Created August 18, 2012 22:39
Singult Lazy Sequence Bug Example
Uncaught TypeError: Object div.child,[object Object] has no method 'match' main.js:25735
singult.coffee.canonicalize_hiccup main.js:25735
singult.coffee.canonicalize main.js:25725
(anonymous function) main.js:25751
singult.coffee.canonicalize_hiccup main.js:25744
singult.coffee.canonicalize main.js:25725
merge_BANG_ main.js:26213
bug main.js:28309
goog.events.Listener.handleEvent main.js:27214
goog.events.fireListener main.js:27548
@aperiodic
aperiodic / boxplots.clj
Created August 18, 2012 08:07
Visual Marginalia Example Usage if I Made All the Decisions
(ns c2-cljs-examples.boxplots
(:use-macros [c2.util :only [bind!]])
(:require [c2.core :as c2]
[c2.event :as event]
[c2.scale :as scale]
[c2.svg :as svg])
(:use [c2.maths :only [extent]]))
(defn crisp
"This makes things look nice and sharp using a magic SVG attribute."
@aperiodic
aperiodic / quil-kinect.core.clj
Created April 13, 2012 09:12
Classloader changes between defsketch and setup
(ns quil-kinect.core
(import SimpleOpenNI.SimpleOpenNI)
(:use quil.core
[quil.applet :only [current-applet applet-close]]))
(def kinect (atom nil))
(defn setup []
(let [_ (println (.getClassLoader clojure.lang.IDeref))
kinect-obj (new SimpleOpenNI (current-applet))
@aperiodic
aperiodic / gist:2341911
Created April 9, 2012 06:13
Strange error when using quil with SimpleOpenNI
Exception in thread "Animation Thread" java.lang.ClassCastException: quil.applet.proxy$processing.core.PApplet$IMeta$c506c738 cannot be cast to clojure.lang.IDeref
at clojure.core$deref.invoke(core.clj:2078)
at quil_kinect.core$setup.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Var.invoke(Var.java:397)
at quil.applet$applet$setup_fn__2190.invoke(applet.clj:192)
at quil.applet$applet$fn__2265.invoke(applet.clj:290)
at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.setup(Unknown Source)
at processing.core.PApplet.handleDraw(Unknown Source)
at quil.applet.proxy$processing.core.PApplet$IMeta$c506c738.handleDraw(Unknown Source)
at processing.core.PApplet.run(Unknown Source)
@aperiodic
aperiodic / .ssh*
Created March 12, 2012 07:23
clojars public key woes
drwxr-xr-x 2 ciel ciel 4096 2012-03-12 00:11 .
drwxr-xr-x 3 ciel ciel 4096 2012-03-12 00:09 ..
-rw-r--r-- 1 ciel ciel 401 2012-03-12 00:08 authorized_keys
-rw------- 1 ciel ciel 1679 2012-03-12 00:10 id_rsa
-rw-r--r-- 1 ciel ciel 390 2012-03-12 00:10 id_rsa.pub
-rw-r--r-- 1 ciel ciel 884 2012-03-12 00:11 known_hosts