Skip to content

Instantly share code, notes, and snippets.

Jed Watson JedWatson

View GitHub Profile

Keybase proof

I hereby claim:

  • I am JedWatson on github.
  • I am jedwatson ( on keybase.
  • I have a public key whose fingerprint is 75DB 2419 8E41 BF37 4E39 88F9 5D4F 4D18 EF37 8B10

To claim this, I am signing this object:

JedWatson / Flick.js
Created Jul 12, 2015
Declarative Interaction Component
View Flick.js
<Flick settings={...}>
{velocityDelta =>
currentVelocity={currentVelocity => velocityDelta === 0 ? currentVelocity :
increase(currentVelocity, velocityDelta)
{currentValues => <div />}
JedWatson / renderComponentToStringAndCSS.js
Last active Aug 29, 2015
View renderComponentToStringAndCSS.js
var MyComponent = React.createComponent({
render () {
return <div style={{ color: 'blue' }}>Hello World</div>;
var page = React.renderComponentToStringAndCSS(MyComponent);
// value of page:
page = {
html: '<div className="__a" data-reactid=".abc" data-react-checksum="123" data-react-classname="__a">Hello World</div>',
JedWatson / async.js
Last active Jan 3, 2016 — forked from getify/gist:8459026
Comparison between (my) old callback-structured code, @getify's asynquence refactor, and my async refactor
View async.js
var doQuery = function() {
// passing an object to async.parallel will cause it to collect their results
// and provide them to the callback in an object with the same keys.
// functions are passed a callback with the standard argument pattern of fn(err, result)
count: count.exec,
query: query.exec
}, function(err, results) {
JedWatson / async.js
Last active Jan 3, 2016 — forked from getify/async.js
Another refactor of a refactor, this time w/o all original comments but w/ proposals. Not currently possible with asynquence, but maybe? *nudge*
View async.js
var transform = function(contents, doneTransform) {
var authExpiry = 60 * 60 * 1000,
authId = uuid.v4(),
authKey = 'file:auth:' + authId;
redis.client.set(authKey, JSON.stringify({
redis.client.expire(authKey, authExpiry);
JedWatson / styles.jsx
Created Apr 5, 2016
A simple thought experiment demonstrating concepts I'm thinking about for styling react components in javascript
View styles.jsx
import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import useSheet from 'react-jss';
import CloudinaryImage from './CloudinaryImage';
const Author = ({image, name}, {theme}) => {
const classes = useSheet(stylesheet, theme);
const { authorKey, bio, id, image, name, summary, urlPath } = this.props;
JedWatson / files.js
Created Apr 8, 2016
File Field Scratchpad
View files.js
var S3Storage = require('keystone-storage-s3');
keystone.addStorage('s3bucket1', S3Storage, {
key: 'my key',
bucket: 'keystone-stuff',
secret: 'abracadabra',
JedWatson / localfile.js
Created Apr 11, 2016
LocalFile Contents Scratch
View localfile.js
{ fieldname: 'file',
originalname: 'Advanced',
name: '',
encoding: '7bit',
mimetype: 'text/markdown',
path: '/var/folders/ck/y02pffhs31xd_k4xc9xmn3hw0000gn/T/',
extension: 'md',
size: 7703,
truncated: false,
buffer: null } }
JedWatson / UserStore.js
Created Mar 26, 2015
Simple store-prototype example for a User Store + View
View UserStore.js
var Store = require('store-prototype');
var UserStore = new Store();
var users = {};
var loaded = false;
loadUsers: function() {
loadUsersSomehow(function(err, results) {
users = results;
JedWatson / async.js
Last active Mar 1, 2018
Example usage of to update an array against a redis cache
View async.js
// This function takes a contents object with a files array.
// The goal is to cache each file details in redis then replace
// the file's path with a secure, obscured url.
// Finally the contents object is returned with the updated array
// in place of the old one.
// async = require('async')
// uuid = require('node-uuid')
// redis.client = require('node-redis').createClient()
You can’t perform that action at this time.