Skip to content

Instantly share code, notes, and snippets.

View tdreyno's full-sized avatar

Thomas Reynolds tdreyno

  • Portland, OR
  • 08:11 (UTC -07:00)
View GitHub Profile
@tdreyno
tdreyno / DataModel.js
Created February 23, 2015 20:55
Google I/O 2015 Experiment Data Serializer
var PIXI = require('pixi.js/bin/pixi.dev.js');
/**
* Data model and serialization.
*/
module.exports = (function() {
'use strict';
/**
* URL-safe character mapping.
header: {
childrenGenerator: [
{ component: Sorter, options: {
options: _ => TeamStore.getAllSorted(),
value: _ => this.state.team,
stringKey: "name",
modifier: "-large -float",
onChange: _ => this.handleTeamChange,
showAll: "Instrument" } },
getAll: function(withDeleted) {
return _(this[collectionName])
.keys()
.map(k => this[collectionName][k])
.filter(o => !withDeleted && !o.deletedAt)
.value();
},
var Immutable = require("immutable"),
t = require("transducers-js"),
comp = t.comp,
map = t.map,
filter = t.filter,
transduce = t.transduce;
var inc = function(n) { return n + 1; };
var isEven = function(n) { return n % 2 == 0; };
var sum = function(a,b) { return a+b; };
class Middleman::SplitterExtendion < ::Middleman::Extension
option :split_count, 2, 'How many files to split into'
option :split_files, nil, 'Which files to split'
register :splitter
def initialize(app, options_hash={}, &block)
super
require 'css_splitter/splitter'
(defn home-api-map
[]
{ :banner (model/pick :banner {:where {:slug "home"}})
:intro-headline (model/pick :headline {:where {:slug "intro"}})
:intro-slides (model/gather :slides {:where {:slug "intro"} :include {:slides {}}})
:intro-highlights (model/gather :highlight {:where {:slug "intro"}})
:tenants (model/gather :tenant)
:partners (model/gather :neighborhood-partner)
:whats-here-headline (model/pick :headline {:where {:slug "whats-here"}})
@tdreyno
tdreyno / ajax.cljs
Created September 2, 2013 02:24
Parallel json loading in CLJS
(defn load-json-channels-in-parallel
[channels]
(let [ch (chan)]
(go
(loop [open-channels channels
data {}]
(if (empty? open-channels)
(do
(>! ch data)
(close! ch))
@tdreyno
tdreyno / body-class.cljs
Created August 30, 2013 01:12
Port of hoverable body class support from JS to CLJS
(defn setup-scroll-watcher
[body-class]
(let [body-class (name body-class)
listener (shared/listen js/window :scroll)
debounced (shared/debounce listener 200)]
(dom/add-class! (.-body js/document) body-class)
(go
(loop []
// Option A
.slide-show__paging-button--next {
float: right;
}
// Option B
.Slideshow-pagingButton--next {
float: right;
}
@mixin hoverable {
.hover &:hover {
@content;
}
}
#elem {
@include hoverable {
font-weight: bold;
}