Skip to content

Instantly share code, notes, and snippets.

@cowboy
cowboy / json-with-comments-in.yaml
Last active August 29, 2015 13:56
Why do we keep having the "comments in JSON" discussion? Just use YAML.
{
# this is a comment
"a": "hello",
# this is another comment
"b": -1,
"c": [
true,
"test",
null
],
@cowboy
cowboy / globule-test.md
Created February 19, 2014 17:48
globule: work in progress

Script

var globule = require('./lib/globule');

globule.find([
  '**/*.js',
  '!**/*built.js',
  '**/*.js',
  '**/*.js',
@cowboy
cowboy / jQuery-deferreds-wtf-anger.js
Last active August 29, 2015 13:56
Man, jQuery Deferreds annoy the fuck out of me.
// When a jQuery deferred is resolved with a single value, the arguments to
// the .then callback are the same as when .then is called directly on the
// deferred or on $.when(deferred) AND ALSO $.when(deferred, deferred).
var dfd = $.Deferred().resolve([1, 2, 3]);
dfd.then(function(a) {
console.log('[1a]', a); // [1, 2, 3]
});
$.when(dfd).then(function(a) {
console.log('[2a]', a); // [1, 2, 3]
});
@cowboy
cowboy / Gruntfile.js
Created March 4, 2014 16:20
Grunt: async config using a wrapper task
module.exports = function(grunt) {
grunt.initConfig({});
grunt.registerTask('require-wrapper', 'whatever', function() {
var done = this.async();
var args = this.args;
// simulate async config building
setTimeout(function() {
// set config
grunt.config('requirejs', {yay: true});
@cowboy
cowboy / globule-mapping-rename.js
Last active August 29, 2015 13:57
globule.mapping new rename src/dest example
var globule = require('globule');
// This actually looks for files '1' '2' etc, doesn't find them,
// but retains the pattern because nonull == true
console.log(globule.findMappingSync({
src: '12345'.split(''),
nonull: true,
rename: function(n) {
return {
src: 'in/' + n + '.txt',
@cowboy
cowboy / Gruntfile.js
Created March 20, 2014 16:20
Grunt toStringify hackery
module.exports = function(grunt) {
function toStringify(obj, toString) {
obj.toString = toString;
return obj;
}
grunt.initConfig({
stuff: {
foo: ['l', 'o', 'l'],
bar: toStringify(['w', 'u', 't'], function() {
@cowboy
cowboy / AutoHotkey.ahk
Created April 17, 2014 02:06
AutoHotkey Misc
SoundPlay *64
; =============
; Edit & Reload
; =============
!^+F12::
Edit
Reload
return
@cowboy
cowboy / wat.js
Created April 25, 2014 19:52
why do i do this kind of thing
(function() {
var $=['_'].concat(Array(arguments.length-1),'return _');
var _=Function.apply(null,$);
$.forEach.call(arguments,function($,$$){_[$$]=$});
return $.map.bind.call($.map,_,_);
}(5,6,7,8))()
@cowboy
cowboy / not-grunt-init.sh
Created May 7, 2014 21:01
Grunt: Look, I re-integrated grunt-init back into grunt. Here ya go, @rwaldron
# (Include this function in your .bashrc)
# If the first argument is "init" or begins with "init:", run grunt-init.
# Otherwise run grunt.
function grunt() {
if [[ "$1" =~ ^init: ]]; then
grunt-init "${1##init:}" "${@:2}"
elif [ "$1" == "init" ]; then
grunt-init "${@:2}"
else
@cowboy
cowboy / gruntjs-org-commits.txt
Created May 14, 2014 02:57
Commits across all Grunt projects
1843 cowboy@rj3.net (Ben Alman, cowboy)
1202 tyler@sleekcode.net (tkellen, Tyler Kellen)
695 kyle@dontkry.com, kyle@kyletyoung.com (Kyle Robinson Young, Kyle ☱☲☳☴☵☷ ☶ Robinson ☱☲ ☳☴☵☶☷ Young, shama)
402 vlad.filippov@gmail.com (Vlad Filippov, vladikoff)
388 sindresorhus@gmail.com (Sindre Sorhus, sindresorhus)
239 chris@christalkington.com, chris@talkingtontech.com (Chris Talkington, ctalkington)
138 joverson@onehealth.com, joverson@onerecovery.com, jsoverson@gmail.com (Jarrod Overson, jsoverson)
67 isaacdurazo@gmail.com (isaacdurazo)
44 jellyes2@gmail.com (James Smith, Jmeas, Jmeas Smith)
27 joern.zaefferer@gmail.com (Jörn Zaefferer, Jörn Zaefferer)