Skip to content

Instantly share code, notes, and snippets.

View michaelsbradleyjr's full-sized avatar
💭
Dip trip, flip fantasia 🎺

Michael Bradley michaelsbradleyjr

💭
Dip trip, flip fantasia 🎺
View GitHub Profile
@michaelsbradleyjr
michaelsbradleyjr / Jolt-small-sample.coffee
Created October 2, 2011 04:02
A very small (and trivial) sample of Jolt in action
Jolt = require 'Jolt'
Jolt.globalize() # places the Jolt API, _, and EventEmitter in the global scope
# Jolt embeds the cross-platform EventEmitter2 library, aliased as EventEmitter
myEmitter = new EventEmitter
myB = $B ($E myEmitter, 'event').mapE((x, y, z) ->
[z, y, x]).nary(true), 0, 0, 0 # initial Behavior value set beyond 1st argument position
liftB ((a, b, c) ->
// CoffeeScript version
EventEmitter = (require 'events').EventEmitter
class Client extends EventEmitter
// JavaScript version (above code compiled with `coffee -bc <file>`
var Client, EventEmitter;
@michaelsbradleyjr
michaelsbradleyjr / Emacs.md
Created December 20, 2011 08:43
Setting up Emacs daemon on OS X

Setting up Emacs daemon on OS X

Tired of waiting for emacs to start on OS X? This step by step guide will teach you how to install the latest version of emacs and configure it to start in the background (daemon mode) and use emacsclient as your main editor.

Install Homebrew

First you'll need to install the [Homebrew package manager][brew] if yo haven't already. It is amazing.

# Particle definitions
# "Particle" serves as the base class, and we'll define specific particle types
# as subclasses
exports.Particle = class Particle
constructor: (@id) ->
@alreadyCalcCE = {}
name: 'unnamed'
charge: 0
dipole: 0
@michaelsbradleyjr
michaelsbradleyjr / testperms.coffee
Created December 26, 2011 20:55
Faster algorithm
util = require 'util'
width = 100
height = 100
population = width * height
charged = (c for c in [1..population])
chargedCopy = charged.slice 0
clen = charged.length
(ns ncljsc
(:require [cljs.closure :as closure]))
(def comp-options {})
(def deps-options {})
(def optm-options {:optimizations :advanced :pretty-print true})
(defn build
[source]
(ns hello
(:require [cljs.nodejs :as nodejs]
[foo :as foo]))
;;(def foo (.-foo (nodejs/require "./foo")))
(defn ^:export greet [n]
;;(str "Hello, " (.title foo n)))
(str "Hello, " (foo/title n)))
(ns quick
(:require [cljs.nodejs :as nodejs]))
(println "hello")
(def util (nodejs/require "util"))
(println (.inspect util nodejs/process))
(ns learn-all-the-things)
(require 'clojure.xml)
(defn twitter-followers
[username]
(->> (str "https://api.twitter.com/1/users/show.xml?screen_name=" username)
clojure.xml/parse
:content
(filter (comp #{:followers_count} :tag))
(defn neighbours
[[x y]]
(for [dx [-1 0 1] dy [-1 0 1] :when (not= 0 dx dy)]
[(+ dx x) (+ dy y)]))
(defn step
"Yields the next state of the world"
[cells]
(set (for [[loc n] (frequencies (mapcat neighbours cells))
:when (or (= n 3) (and (= n 2) (cells loc)))]