Skip to content

Instantly share code, notes, and snippets.

Avatar

Ben Alman cowboy

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

Script

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

globule.find([
  '**/*.js',
  '!**/*built.js',
  '**/*.js',
  '**/*.js',
@cowboy
cowboy / jQuery-deferreds-wtf-anger.js
Last active Aug 29, 2015
Man, jQuery Deferreds annoy the fuck out of me.
View jQuery-deferreds-wtf-anger.js
// 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 Mar 4, 2014
Grunt: async config using a wrapper task
View Gruntfile.js
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 Aug 29, 2015
globule.mapping new rename src/dest example
View globule-mapping-rename.js
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 Mar 20, 2014
Grunt toStringify hackery
View Gruntfile.js
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 Apr 17, 2014
AutoHotkey Misc
View AutoHotkey.ahk
SoundPlay *64
; =============
; Edit & Reload
; =============
!^+F12::
Edit
Reload
return
@cowboy
cowboy / wat.js
Created Apr 25, 2014
why do i do this kind of thing
View wat.js
(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
Grunt: Look, I re-integrated grunt-init back into grunt. Here ya go, @rwaldron
View not-grunt-init.sh
# (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
Commits across all Grunt projects
View gruntjs-org-commits.txt
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)