Skip to content

Instantly share code, notes, and snippets.

View shama's full-sized avatar
✍️
writing a status message

Kyle Robinson Young shama

✍️
writing a status message
View GitHub Profile
@shama
shama / cmdexe
Last active December 23, 2015 18:19
node v0.10.18
C:\Users\Office\Documents\www\node-exit>grunt nodeunit
Running "nodeunit:files" (nodeunit) task
Testing exit_test.jsF..F
>> exit - stdout stderr
>> Message: node log.js 0 1000 stdout stderr
>> Error: true == '**UNEXPECTED** [stderr] testing 10\n**UNEXPECTED** [stderr] testing 11\n**EXPECTED** [stderr] testing 10\n**UNEXPECTED** [stderr] testing 12\n**EXPECTED** [stderr] testing 11\n**UNE
XPECTED** [stderr] testing 13\n**EXPECTED** [stderr] testing 12\n**UNEXPECTED** [stderr] testing 14\n**EXPECTED** [stderr] testing 13\n**UNEXPECTED** [stderr] testing 15\n**EXPECTED** [stderr] testing
14\n**UNEXPECTED** [stderr] testing 16\n**EXPECTED** [stderr] testing 15\n**UNEXPECTED** [stderr] testing 17\n**EXPECTED** [stderr] testing 16\n**UNEXPECTED** [stderr] testing 18\n**EXPECTED** [stder
r] testing 17\n**UNEXPECTED** [stderr] testing 19\n**EXPECTED** [stderr] testing 18\n**UNEXPECTED** [stderr] testing 20\n**EXPECTED** [stderr] testing 19\n**UNEXPECTED** [stderr] testing 21\n**EXPECTE
D** [stderr] testing 20\n**UNE
@shama
shama / setfromdb.js
Last active December 24, 2015 01:29
Grunt example setting config from a db
grunt.initConfig({
db: {
// Books will be populated when setfromdb is ran
books: []
},
other: {
target: {
options: {
// Now when other:target is ran it will consume db.books
books: '<%= db.books %>'
uglify: {
test: {
files: [{
expand: true,
cwd: 'test/fixtures/',
src: '**/*.js',
dest: 'tmp/things',
ext: '.min.js',
}]
}
@shama
shama / removeline.js
Created October 1, 2013 22:33
Remove a line of code in a bunch of files
#!/usr/bin/env node
var falafel = require('falafel');
var globule = require('globule');
var fs = require('fs');
var path = require('path');
// Remove this line
var line = "grunt.verbose.writeflags(options, 'Options');";
@shama
shama / cmd
Created October 9, 2013 05:10
grunt.file.setPermissions windows 7, node v0.10.18
C:\Users\Office\Documents\www\grunt>grunt
Running "jshint:gruntfile_tasks" (jshint) task
>> 2 files lint free.
Running "jshint:libs_n_tests" (jshint) task
>> 24 files lint free.
Running "jshint:subgrunt" (jshint) task
>> 1 file lint free.

spawn: false

$ grunt watch
Running "watch" task
Waiting...
>> File "test/fixtures/banner/banner.styl" changed.

Running "stylus:compile" (stylus) task
File tmp/stylus.css created.
@shama
shama / Gruntfile.js
Created February 24, 2014 19:12
Simple gruntfile that compiles with compass
module.exports = function(grunt) {
grunt.initConfig({
compass: {
dist: {
options: {
sassDir: 'sass',
cssDir: 'css',
environment: 'production',
},
},
@shama
shama / favorite_module_pattern.js
Last active August 29, 2015 13:57
My favorite node.js module pattern
function Animal(name) {
if (!(this instanceof Animal)) return new Animal(name);
this.name = name || 'unknown';
}
module.exports = Animal;
Animal.prototype.feed = function(food) {
food = food || 'food';
return 'Fed ' + this.name + ' some ' + food;
};

Method for triggering an action on any controller from a component, such as with nested Ember components.

WARNING: You really shouldn't do this as it couples your component to your app, which kind of defeats the purpose of the component, right?

GlobalAction = Ember.Mixin.create
  triggerGlobalAction: (action, controller="application", args...) ->
    @triggerAction
      action: action
 target: @container.lookup('controller:' + controller)
@shama
shama / async-vs-sync.js
Created April 25, 2014 16:20
Comparing async vs sync functions in node.js
function sync(callback) {
callback()
}
function async(callback) {
process.nextTick(function() {
callback()
})
}