Skip to content

Instantly share code, notes, and snippets.

View mhuebert's full-sized avatar

Matt Huebert mhuebert

View GitHub Profile
urlPattern = require('url-pattern')
RouterMixin =
getInitialState: ->
match: this.match(this.props.path || window.location.pathname)
navigate: (path, callback) ->
window.history.pushState(null, null, path)
this.setState({ match: this.match(path) }, callback)
### Keybase proof
I hereby claim:
* I am mhuebert on github.
* I am mhuebert (https://keybase.io/mhuebert) on keybase.
* I have a public key whose fingerprint is F0C9 8331 CCA1 0DA3 5719 93D7 A5F1 2850 30B8 1AE7
To claim this, I am signing this object:
@mhuebert
mhuebert / docprint.clj
Last active August 29, 2015 14:06
Clojure macro for printing docstrings as functions are called (eventually, interpolated w/ args)
(ns prndoc.core
(require
[clojure.core.strint :refer [<<]]
[clojure.core.match :refer [match]]))
(defn has-splat? [arglist]
((complement nil?) (first (last (split-with #(not= % '&) arglist)))))
(defn parse-arg-pattern
"Argument pattern [num-args has-splat?]. Pattern of [func & body] is [1 true]."
@mhuebert
mhuebert / Humpty Dumpty.md
Last active August 29, 2015 14:06
Humpty Dumpty in Clojure.
(ns humpty.core
  (require [clojure.set :refer [subset?]]))

Humpty Dumpty

Humpty Dumpty

@mhuebert
mhuebert / clojure-markdown.js
Last active August 29, 2015 14:21
Clojure-Markdown CodeMirror mode
CodeMirror.defineMode("clojure-markdown", function(options){
var clojureMode = CodeMirror.getMode({}, "clojure");
var markdownMode = CodeMirror.getMode({}, "markdown");
return {
startState: function() {
return {
mode: markdownMode,
@mhuebert
mhuebert / reagent-cursors-test.cljs
Created July 4, 2015 23:20
Reagent Cursors Test
(ns app.layout
(:require
[reagent.core :as r]
[reagent.cursor :refer [cursor]]))
(defonce my-state (r/atom {1 "aaa"
2 "bbb"}))
(defn display-item [item-cursor id]
(fn []
@mhuebert
mhuebert / core.cljs
Last active August 29, 2015 14:25
CLJS javascript dependency load order?
; I want to use the files referenced in deps.cljs
; - CodeMirror must run before -overlay, -subpar, and -match-brackets.
(ns my-project.core
(:require
[CodeMirror]
[CodeMirror-overlay]
[CodeMirror-subpar]
[CodeMirror-match-brackets]
[reagent.core :as r :refer [cursor]]
@mhuebert
mhuebert / oculus-mac-2015-july-30.md
Last active August 29, 2015 14:26
Oculus - Unity - Mac, July 30 / 2015

assuming you've already installed the Oculus runtime & it's working on your machine

  1. start unity (version 5.1.2f1 - download)
  2. edit > project settings > player, scroll to the bottom of panel on right side of page, "Other Settings", check "Virtual Reality Supported"
  3. command-p exits full-screen (remember this - ESC does not work)
  4. assets > import package > custom package... - select OculusUtilities.unitypackage (download)
  5. on the pop-up panel- keep selections as-is, just click import
  6. see "assets" panel at bottom of window. double-click OVR > Scenes > Cubes (or whatever scene you want)
  7. press play
@mhuebert
mhuebert / eval-with-ns.cljs
Last active August 29, 2015 14:26
`def` in a namespace, cljs.js/eval
(cljs/eval (cljs/empty-state)
'(def x 1)
{:eval cljs/js-eval
:context :expr
:def-emits-var true
:ns cells.core
}
#(pprint %))
@mhuebert
mhuebert / cljs-example.md
Last active August 29, 2015 14:26
ClojureScript with zero dependencies (browser)

ClojureScript from master w/ zero dependencies

  1. git clone https://github.com/clojure/clojurescript.git
  2. cd clojurescript; ./scripts/uberjar
  3. (^this creates cljs.jar in clojurescript/target; you will use it below)
  4. Create the following directory & file structure
 foo
 ├── build.clj