Skip to content

Instantly share code, notes, and snippets.

View NickHeiner's full-sized avatar
💭
Wubba lubba dub dub!!

Nick Heiner NickHeiner

💭
Wubba lubba dub dub!!
View GitHub Profile
@NickHeiner
NickHeiner / test-fail
Created December 3, 2013 18:30
Failure from running `npm test` in npm on master
> [email protected] test /Users/nick.heiner/public-projects/npm
> node ./test/run.js && tap test/tap/*.js
# testing in /var/folders/6v/3scp840j6gzgwzp0ctz_xx_40000gp/T/npm-test-38506
# global prefix = /var/folders/6v/3scp840j6gzgwzp0ctz_xx_40000gp/T/npm-test-38506/root
ok 1 node "/Users/nick.heiner/public-projects/npm/bin/npm-cli.js" install "/Users/nick.heiner/public-projects/npm"
ok 2 npm config set package-config:foo boo
ok 3 npm install /Users/nick.heiner/public-projects/npm
ok 4 npm install packages/npm-test-array-bin
module.exports = function(grunt) {
grunt.initConfig({
foo: {
options: {
bar: {
minify: true,
scripts: ['a', 'b', 'c']
}

Is this worth it?

I've been editing this in response to comments below, but I will preserve the full revision history.

Referencing the function execution context via this is fairly common in JavaScript. I suspect some people like it because they come from a language like Java, and it’s familiar. However, I would argue that it in some cases introduces brittleness into one's code without bringing much benefit.

For example, let’s consider a contrived logger module:

function CountingLogger() {
 if (!(this instanceof CountingLogger)) return new CountingLogger;

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@NickHeiner
NickHeiner / .bowerrc
Created February 13, 2015 23:37
A sample .bowerrc
{
"endpoint": "http://bower.opower.it/",
"searchpath": [
"https://bower.herokuapp.com"
],
"registry": {
"search": [
"http://bower.opower.it/",
"https://bower.herokuapp.com"
],
@NickHeiner
NickHeiner / deps.txt
Created February 13, 2015 23:38
sample dependency tree
A
└── B
│ └── E
└── C
│ └── E’
└── D
└── E’’
@NickHeiner
NickHeiner / bower
Created February 13, 2015 23:41
Single entry of a bower json
"lodash": "^2.4.1"
@NickHeiner
NickHeiner / Gruntfile.js
Created February 17, 2015 23:37
A sample gruntfile
'use strict';
var sdk = require('internal-sdk');
module.exports = function(grunt) {
sdk(grunt, {
'project-type': 'widget'
});
};
@NickHeiner
NickHeiner / task.js
Created February 17, 2015 23:54
Grunt task control flow - a nicer way
grunt.registerTask(‘task-a’, function() {
var result = doStuff();
grunt.task.run(‘task-b’).then(function() {
doMoreStuff();
});
});
@NickHeiner
NickHeiner / task.js
Last active August 29, 2015 14:15
Grunt task control flow - the real way
grunt.registerTask(‘task-a’, function() {
var result = doStuff();
grunt.registerTask(‘after-task-b’, function() {
doMoreStuff(result);
});
grunt.task.run(‘task-b’);
grunt.task.run(‘after-task-b’);
});