Skip to content

Instantly share code, notes, and snippets.

@stevemao
stevemao / np.sh
Last active June 15, 2022 00:37 — forked from sindresorhus/np.sh
Publish node module
# npm publish with goodies
# prerequisites:
# `npm install -g trash conventional-recommended-bump conventional-changelog conventional-github-releaser conventional-commits-detector json`
# `np` with optional argument `patch`/`minor`/`major`/`<version>`
# defaults to conventional-recommended-bump
# and optional argument preset `angular`/ `jquery` ...
# defaults to conventional-commits-detector
np() {
travis status --no-interactive &&
trash node_modules &>/dev/null;
@naholyr
naholyr / Makefile
Last active March 6, 2018 17:02
browserify-friendly Makefile
# Main entry point
SOURCE = src/app.js
# The dependencies (other than node_modules/**)
LIBS = $(shell ls src/lib/*.js src/components/*.js)
# The target
TARGET = build/app.js
# Compilation flags
@constantology
constantology / process.logger.js
Created July 24, 2014 09:39
using node's process to emit events to log stuff from anywhere
// use like this:
// process.emit( 'app:log', module, arg1, arg2, ..., argN );
var Module = require('module');
function logConsole(method, module) {
var args = [(new Date()).toJSON(), method];
var index = 1;
if (module instanceof Module) {
@thom4parisot
thom4parisot / convert-helpers.js
Last active August 29, 2015 13:58
XML Stream Update
'use strict';
var STYLE_ATTRIBUTE = 'text-style-name';
var styleMatches = function (item, styleName) {
if (!item || item.attributes === undefined || item.attributes[STYLE_ATTRIBUTE] === undefined) {
return false;
}
return item.attributes[STYLE_ATTRIBUTE].match(styleName);
@ricardobeat
ricardobeat / node-0.8.20-hangup.js
Created February 21, 2013 19:27
Silence socket hangup errors.
function hangups (req, res, next){
var reqd = domain.create()
reqd.add(req)
reqd.add(res)
reqd.on('error', function (error) {
if (error.code !== 'ECONNRESET') console.error(error, req.url)
reqd.dispose()
})
next()
}
@desandro
desandro / bower-logo.md
Last active December 30, 2021 23:11
Bower logo

In addition to awesome docs #228, Bower deserves a proper logo. See below for sketches. I'm curious if you think any of these are worth me putting more effort into.


Take a look at Yeoman right now.

Screen Shot 2013-02-19 at 4 43 10 PM

The other two entities have awesome logos. Bower's got to represent.

diff --git a/lib/module.js b/lib/module.js
index 6130394..80559f4 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -25,6 +25,7 @@ var runInThisContext = Script.runInThisContext;
var runInNewContext = Script.runInNewContext;
var assert = require('assert').ok;
+var timeRequire = +process.env.NODE_TIME_REQUIRE;
@dherman
dherman / range-error-ftw.js
Created November 27, 2012 22:53
fun with JS arrays
var a = [];
a[Math.pow(2, 32) - 2] = "max index"; // highest non-expando indexed property
console.log(a.length === Math.pow(2, 32) - 1); // true
try {
a.push("whoa", "EVEN MOAR WHOA");
} catch (e) {
console.log(e instanceof RangeError); // true
}
@naholyr
naholyr / git-pr.md
Created November 22, 2012 18:11
Using "hub" to automatically push & PR

git-pr

Part of my personal shortcuts for the usual pull-request-based workflow.

Setup

Given you have an "upstream" repository you need to work on:

  1. Fork it
  2. Clone your fork locally (repo "origin")
@piscisaureus
piscisaureus / pr.md
Created August 13, 2012 16:12
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this: