Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt McCray mattmccray

  • Elucidata unLTD
  • Dallas, TX
View GitHub Profile
@mattmccray
mattmccray / tooltip-mgr.js
Last active Aug 26, 2015
Tooltip Manager with Mobservable (simplified)
View tooltip-mgr.js
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({})
View sftp_publisher.rb
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
View package.json
{
"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 <matt@elucidata.net>",
@mattmccray
mattmccray / component.coffee
Last active Aug 29, 2015
Build React Components using natural CoffeeScript syntax.
View component.coffee
# Public: Define components as CoffeeScript classes
#
# Example:
#
# class UserChip extends Component
#
# @staticMethod: -> # becomes a static method on the React Component
# "hello"
#
# render: ->
View example.litcoffee

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:

util.coffee:

module.exports= 
  log: (msg)->
@mattmccray
mattmccray / ng-core.coffee
Last active Aug 29, 2015
A CoffeeScript-rific way of using AngularJS.
View ng-core.coffee
# Requires SugarJS...
@Ng=
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
mattmccray / sftp.thor.rb
Created Jul 26, 2008
Thor task for sftp syncing
View sftp.thor.rb
# 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
mattmccray / range.js
Created Oct 13, 2014
Creates a 'range' Array, extracted from Liquid.js
View range.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
mattmccray / 0_reuse_code.js
Last active Aug 29, 2015
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mattmccray
mattmccray / 1_example.md
Last active Aug 29, 2015
StyleBuilder for React components
View 1_example.md

StyleBuilder

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.