Skip to content

Instantly share code, notes, and snippets.

View mhuebert's full-sized avatar

Matt Huebert mhuebert

View GitHub Profile
mongo_db = case Padrino.env
when :development then "overlap-dev-test-local"
when :production then "overlap-01"
when :test then "overlap-01-test"
end
port = case Padrino.env
when :development then "27017"
when :production then "27051"
when :test then "27031"
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)
@mhuebert
mhuebert / React with Firebase.litcoffee
Last active November 25, 2016 05:01
React Firebase Mixin

I'm trying to find a good way to use React with Firebase. There are three main things going on here:

  1. A router mixin in my root component matches a path to a Handler component.
  2. the Handler component specifies the data it requires in statics.firebase.
  3. a FirebaseMixin handles subscription/unsubscription to Firebase data.

All of this works on the client and server (express middleware is at the bottom)

Data Dependencies

### 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