Skip to content

Instantly share code, notes, and snippets.

View mattmccray's full-sized avatar

Matt McCray mattmccray

View GitHub Profile
mattmccray / tooltip-mgr.js
Last active August 26, 2015 19:56
Tooltip Manager with Mobservable (simplified)
import {makeReactive, sideEffect, asReference, transaction} from 'mobservable'
function TooltipManager() {
const DOM_ROOT = document.getElementById('tooltip_root')
const LEAVE_DELAY = 400
let state = makeReactive({
hoverCount: 0,
tooltip: asReference(null),
position: asReference({})
require 'find'
require 'rubygems'
require 'digest/md5'
gem 'net-sftp', '<2.0.0'
require 'net/sftp'
class SftpDirPublisher
CHECKSUM_FILENAME = ".checksums"
attr_reader :host, :username, :password, :remote_dir, :local_dir, :exclude
mattmccray / package.json
Created February 17, 2014 04:03
"name": "ogre-js-docs",
"version": "0.1.0",
"description": "Docs for ogre.js",
"main": "server.js",
"scripts": {
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
"author": "Matt McCray <>",
mattmccray /
Last active August 29, 2015 13:57
Build React Components using natural CoffeeScript syntax.
# Public: Define components as CoffeeScript classes
# Example:
# class UserChip extends Component
# @staticMethod: -> # becomes a static method on the React Component
# "hello"
# render: ->

So... I would like to be able to use coffeescript without having to add the ".coffee" extension in my requires (in the lib code, not the test code).

I would guess that in my test a require('coffee-script/register') would work -- but I'd be wrong. :)

For example, I'd like to get this working:

  log: (msg)->
mattmccray /
Last active August 29, 2015 14:04
A CoffeeScript-rific way of using AngularJS.
# Requires SugarJS...
annotateDependencies: (Class, props={})->
Class.$inject or= []
Class.$injected or= []
for name,deps of props
deps= [ deps ].flatten()
Class.$inject.push deps.shift()
Class.$injected.push { name, params:deps }
mattmccray / sftp.thor.rb
Created July 26, 2008 00:04
Thor task for sftp syncing
# module: sftp
# A generic Thor module for sftp syncing.
# 1. Call `thor sftp:setup` to create config file.
# 2. Edit the config file
# 3. Call `tor sftp:sync` start the sync
# Ze end.
mattmccray / range.js
Created October 13, 2014 13:58
Creates a 'range' Array, extracted from Liquid.js
// Creates a 'range' Array, extracted from Liquid.js
function makeRange(from, to) {
var arr= [],
left= parseInt(from),
right= parseInt(to);
// Check if left and right are NaN, if so try as characters
if( isNaN(left + right) ) {
// TODO Add in error checking to make sure ranges are single
// character, A-Z or a-z, etc.
left = from.charCodeAt(0);
mattmccray / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
mattmccray /
Last active August 29, 2015 14:09
StyleBuilder for React components


Simple JS-based StyleSheets with no cascading.

That's right. There is intentionally no support for 'externalizing' the CSS, or any cascading support. This is a feature. Be explicit. It's best for everyone.

Also a feature: CSS variables are expanded as soon as the objects are merged. So no, you can't change a variable and have it automatically update any currently rendered nodes.