Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / gist:1981174
Created March 5, 2012 21:19 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@cowboy
cowboy / ctor-proto.js
Created March 2, 2012 17:23
JavaScript: Prototypal Inheritance, Extend
// Also see http://michaux.ca/articles/class-based-inheritance-in-javascript
function extend(Super, Sub) {
// By using a dummy constructor, initialization side-effects are eliminated.
function Dummy() {}
// Set dummy prototype to Super prototype.
Dummy.prototype = Super.prototype;
// Create Sub prototype as a new instance of dummy.
Sub.prototype = new Dummy();
// The .constructor propery is really the Super constructor.
Sub.baseConstructor = Sub.prototype.constructor;
@cowboy
cowboy / gist:1926484
Created February 27, 2012 19:31 — forked from jnordberg/gist:1926447
npm plugin system
npm = require 'npm'
npm.load {global: true}, (error, npm) ->
npm.commands.ls [], true, (error, result) ->
for moduleName, module of result.dependencies
if moduleName[..8] == 'clitool-'
# load module as a plugin
@cowboy
cowboy / grunt.js
Created February 16, 2012 21:06
Packify grunt task (in a gist just for now)
/*
* grunt
* https://github.com/cowboy/grunt
*
* Copyright (c) 2012 "Cowboy" Ben Alman
* Licensed under the MIT license.
* http://benalman.com/about/license/
*/
/*global config:true, task:true*/
@cowboy
cowboy / blog-comment.txt
Created February 13, 2012 17:45
just something i typed earlier today
As a frequent consumer of ironic entertainment, there’s little I enjoy more than
reading a well-reasoned article only to be confronted by inconsistencies in the
article author’s comments. But as an unfortunately-not-nearly-as-frequent consumer
of consistent analytic reasoning, the aforementioned “little” would a well-reasoned
article in which the author’s comments are just as well reasoned and consistent.
@cowboy
cowboy / tryme.md
Created February 3, 2012 17:10
You can run jQuery's unit tests in grunt!

First, install grunt v0.2.14 (or newer) via npm with npm install -g grunt, if you haven't already done so.

Next, install PhantomJS. If you're on OS X, use homebrew and brew install phantomjs. If you're on Windows or Linux, download from www.phantomjs.org and put it in your path.

Finally, just open a terminal and...

git clone https://github.com/jquery/jquery
cd jquery
git submodule update --init
@cowboy
cowboy / dump.txt
Created February 2, 2012 23:38
jQuery.support running in latest PhantomJS
leadingWhitespace = true
tbody = true
htmlSerialize = true
style = true
hrefNormalized = true
opacity = true
cssFloat = true
checkOn = false
optSelected = true
getSetAttribute = true
@cowboy
cowboy / log.txt
Created February 2, 2012 19:58
this almost actually works
[master:!?][cowboy@cowbook:/Volumes/Data/Dropbox/Projects/Repos/cowboy/forks/jquery-grunt]
[18:21:01] $ gl -1
commit 974e4afbe2b69cdb7e90bf0e7058b6330003f21f
Author: Dave Methvin <[email protected]>
Date: Tue Jan 31 20:11:53 2012 -0500
Updating the source version to 1.7.2pre
[master:!?][cowboy@cowbook:/Volumes/Data/Dropbox/Projects/Repos/cowboy/forks/jquery-grunt]
[18:21:08] $ grunt qunit
@cowboy
cowboy / child.js
Created January 24, 2012 03:21
If a forked node process exits, how can the parent know?
console.log('child spawned');
process.on('exit', function() {
// This never executes.
process.send('exited from within child');
});
function tellParentImDone() {
process.send('hey parent, all done');
}
@cowboy
cowboy / stuff.js
Created January 9, 2012 22:09
pattern matching for tim
[
["/*", "/", "*"],
["/foo", "/", "foo"],
["/foo*", "/", "foo*"],
["/foo*.js", "/", "foo*.js"],
["/foo/*", "/foo/", "*"],
["/foo?", "/", "foo?"],
["/foo?.js", "/", "foo?.js"],
["/foo/?", "/foo/", "?"],
["/bar/foo", "/bar/", "foo"],