Skip to content

Instantly share code, notes, and snippets.

View sindresorhus's full-sized avatar

Sindre Sorhus sindresorhus

View GitHub Profile
@bendc
bendc / nodelist-iteration.js
Created January 13, 2015 14:39
ES6: Iterating over a NodeList
var elements = document.querySelectorAll("div"),
callback = (el) => { console.log(el); };
// Spread operator
[...elements].forEach(callback);
// Array.from()
Array.from(elements).forEach(callback);
// for...of statement
@addyosmani
addyosmani / browserify.md
Last active March 28, 2016 02:06
Yeoman + Browserify

Yeoman generators with Browserify

Browserify is a tool that allows us to write node-style modules that compile for use in the browser. Like node, we write our modules in separate files, exporting external methods and properties using the module.exports and exports variables

generator-browserify is a generator with a Browserify setup, offering choices between Gulp or Grunt and Foundation or Bootstrap.

screenshot 2014-04-20 at 10 19 09 pm

generator-angular-with-browserify is a generator for bundling Angular.js with Browserify

@mikeal
mikeal / gist:9242748
Last active June 23, 2020 05:17
Response to Nodejitsu NPM Trademark

I've known people at nodejitsu for years, since before the company even existed. I still consider many of them friends. That said, somebody over there has lost their mind.

Trademarks are an important part of open source. They protect the integrity of the trust that is built by any project. A classic example of why this is the case is Firefox. Suppose that a malware producer takes the Firefox codebase, which is free and open source, packages up their malware with it and then releases it as "Firefox". Then they buy search advertising and suddenly their bad and malicious version of Firefox is the first result on search engines across the web. This is clearly a bad thing for Firefox and open source everywhere, but what can Mozilla do to protect their community of users?

They can't enforce a software license since the use is permitted under the Mozilla Public License. They can, however, enforce on these hypothetical bad actors using their trademark on the word "Fi

@callumlocke
callumlocke / time-require-calls.js
Created February 19, 2014 09:51
cd into a Node.js project, run node (CLI) and paste this in to time require calls
var modules = require('fs').readdirSync('node_modules').filter(function (name) {return name !== '.bin'});
modules.forEach(function (m) {
console.time(m);
require(m);
console.timeEnd(m);
});
@mikeal
mikeal / gist:8947417
Created February 12, 2014 00:27
NPM history.

[In reply to https://news.ycombinator.com/item?id=7219005]

Here's the history, hope it helps.

I wrote the original version of the npm registry in a day or two on top of CouchDB. I built it quickly and didn't think much about scale.

Isaacs continued to improve and maintain that code. At one point he even wrote up an open standard for generic js package registries for CommonJS but they didn't seem to care (they were too busy arguing about promises).

At the time I wrote the initial code I was employed at CouchOne and we had a small CouchDB hosting platform operated by Jason Smith which is where we ran the registry free of charge. Later on, after CouchOne was aquired by Membase and became Couchbase, it decided to break off the hosting company and give/sell it to Jason Smith, which became IrisCouch.

@mollerse
mollerse / gulpfile-express.js
Last active March 28, 2021 20:07
Gulpfile for livereload + static server
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserify = require('gulp-browserify'),
concat = require('gulp-concat'),
embedlr = require('gulp-embedlr'),
refresh = require('gulp-livereload'),
lrserver = require('tiny-lr')(),
express = require('express'),
livereload = require('connect-livereload')
livereloadport = 35729,
@XVilka
XVilka / TrueColour.md
Last active April 8, 2024 14:02
True Colour (16 million colours) support in various terminal applications and terminals

THIS GIST WAS MOVED TO TERMSTANDARD/COLORS REPOSITORY.

PLEASE ASK YOUR QUESTIONS OR ADD ANY SUGGESTIONS AS A REPOSITORY ISSUES OR PULL REQUESTS INSTEAD!

Disclaimer: I work for Mozilla and am a Node.js core maintainer. The opinions expressed here do not reflect those of Mozilla or the Node.js project.

After watching the events unfold the last 2 days I decided to sit down, with my two cartons of Trader Joe's eggnog, and simply express with all humility and confidence what libuv@47d98b6 definitely was not.

Over the last year I have had the pleasure of being mentored by Ben. He is largely responsible for my initial major involvement writing performance improvements for Node, and has easily surpassed

@sindresorhus
sindresorhus / query-string-example.js
Created November 15, 2013 18:57
Get, set, modify url parameters in a query string with JavaScript.
// Get the queryString module from:
// https://github.com/sindresorhus/query-string
console.log(location.href);
// http://sindresorhus.com/?foo=bar
console.log(location.search);
// ?foo=bar
var parsed = queryString.parse(location.search);
ACTION
AD_HOC_CODE_SIGNING_ALLOWED
ALTERNATE_GROUP
ALTERNATE_MODE
ALTERNATE_OWNER
ALWAYS_SEARCH_USER_PATHS
ALWAYS_USE_SEPARATE_HEADERMAPS
APPLE_INTERNAL_DEVELOPER_DIR
APPLE_INTERNAL_DIR
APPLE_INTERNAL_DOCUMENTATION_DIR