Skip to content

Instantly share code, notes, and snippets.

View chrisdickinson's full-sized avatar

Chris Dickinson chrisdickinson

View GitHub Profile
@chrisdickinson
chrisdickinson / backing.js
Created November 4, 2013 01:02
backing code for examples.
// transform an element + eventName into
// a stream of those DOMEvents over time.
function events(element, eventName, selector) {
var lastEvent
, nextRead
element.on(eventName, selector, onevent)
return {read: read}
@chrisdickinson
chrisdickinson / a.md
Last active December 26, 2015 08:59
examples of how to use my various js-git repos

instructions

make sure to clone this gist! then npm install it then run node example.js

if it doesn't work ping me on twitter (@isntitvacant) or irc (chrisdickinson in #pdxnode on freenode.net)

@chrisdickinson
chrisdickinson / lookup_file.js
Last active December 22, 2015 22:59
git-fs-repo load file at path and hash
var repo = require('./index')
, path = require('path')
, dir = path.resolve(
__dirname
, '..'
, '..'
, 'personal'
, 'plate'
, '.git'
)
@chrisdickinson
chrisdickinson / json.go
Last active December 22, 2015 14:09
my first and second go programs. 1 TCP echo server, 1 JSON parser.
package main
import "math"
import "container/list"
import "strconv"
//import "fmt"
import "os"
import "encoding/json"
import "runtime/pprof"
@chrisdickinson
chrisdickinson / index.js
Created August 28, 2013 18:05
requirebin sketch
var term = require('hypernal')()
term.appendTo(document.body);
var termEl = term.term.element
termEl.style['font'] = '13px Monaco, mono'
termEl.style.height = '100%'
termEl.style.padding = '5px'
termEl.style.overflow = 'auto'
termEl.style['white-space'] = 'pre'
@chrisdickinson
chrisdickinson / index.js
Created August 24, 2013 17:50
requirebin sketch
var voice = require('mespeak/voices/en/en-us.json')
, debounce = require('debounce')
, mespeak = require('mespeak')
var input = document.createElement('input')
mespeak.loadVoice(voice)
input.type = 'text'
input.style.padding = '12px 8px'
@chrisdickinson
chrisdickinson / estimate.js
Last active December 20, 2015 23:39
round one
var language = require('cssauron-falafel')
, concat = require('concat-stream')
, falafel = require('falafel')
, through = require('through')
, ls = require('ls-stream')
, path = require('path')
, fs = require('fs')
var methods = [
Number
module.exports = check_trailing_newline
var subsource = require('../utils/source')
// require blank newline after major statements
// and after blocks of expression statements.
function check_trailing_newline(node, errors, warnings, source) {
var body = Array.isArray(node.parent.body) ? node.parent.body : node.parent.body.body
, idx = body.indexOf(node)
, parent_src
@chrisdickinson
chrisdickinson / client.js
Last active December 15, 2015 16:38
based on the newly released `git-list-pack` stream; this is an example of cloning repos from the browser. use `browserify client.js > bundle.js` to compile.
var shoe = require('shoe')
, fetch = require('git-fetch-pack')
, unpack = require('git-list-pack')
, through = require('through')
, Buffer = require('buffer').Buffer
// make a websocket connection to the
// server.
var conn = shoe('/git')
, client
@chrisdickinson
chrisdickinson / index.js
Last active December 15, 2015 08:49
duplex stream wrapping a line-delimited json protocol
var lines = require('line-stream')
, through = require('through')
, emit = require('emit-function')
, duplex = require('duplex')
module.exports = json
function json(transport) {
var input = through(write)
, output = through(recv)