Skip to content

Instantly share code, notes, and snippets.

@domenic
domenic / promises.md
Last active April 1, 2025 01:54
You're Missing the Point of Promises

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@TooTallNate
TooTallNate / transcode.js
Last active April 6, 2024 14:03
Transcode an OGG Vorbis audio file to an MP3 using node-ogg, node-vorbis and node-lame
/**
* Module dependencies.
*/
var fs = require('fs');
var ogg = require('ogg');
var lame = require('lame');
var vorbis = require('vorbis');
@joelongstreet
joelongstreet / BeautifulFaces.js
Created February 27, 2013 22:01
Drop this script into your git post-commit hook to take a picture of your face (or butt) every time you make a commit.
#!/usr/bin/env node
var picsPath = process.env['HOME'] + '/.gitshots/';
var imagesnap = require('imagesnap');
var fs = require('fs');
var path = require('path');
var commitPath = picsPath + new Date().getTime();
fs.mkdirParent = function(dirPath, mode, callback) {
fs.mkdir(dirPath, mode, function(error) {
@simshanith
simshanith / example.dev.html
Last active December 16, 2015 15:29
Building dev & production HTML with Jade & Grunt.
<!DOCTYPE html><!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7"><![endif]--><!--[if IE 7]><html class="no-js lt-ie9 lt-ie8"><![endif]--><!--[if IE 8]><html class="no-js lt-ie9"><![endif]--><!--[if gt IE 8]><!-->
<html class="no-js" lang="en"><!--<![endif]-->
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<title>Example Jade Template</title>
<script src="/_assets/js/modernizr-2.6.2.min.js"></script>
</head>
<body>
<h1>Example Jade Template</h1>
@polotek
polotek / event_emitter_example.js
Last active December 17, 2015 22:59
Simple example of a node event emitter
// Grab the EventEmitter constructor. events is a core node module.
var Emitter = require('events').EventEmitter;
// Our internal function will generate random numbers
function randomInt(limit) {
return Math.ceil( Math.random() * limit );
}
module.exports = function(limit) {
if(!(limit && limit > 0)) {
@max-mapper
max-mapper / readme.md
Last active May 28, 2021 17:35
list of things that are like tacos
@ruzz311
ruzz311 / turnip-farmer.txt
Last active April 4, 2025 20:49
The story of the turnip farmer. Weird things are written in the middle of a hackathon. (originally ~ June 2013)
"In all my days as a turnip farmer I have not yet experienced the love of a white radish," thought the farmer as he sighed and walked up the dusty, worn trail towards the barn. The paint, which once was vibrant red had dulled to a rusty hue where the paint had not yet freed itself from the siding, leaving chunks of exposed rough wood that he ran his hands along. The man braced his back against the worn but sturdy structure and slowly sank until his knees could take no more and he crumpled against the barn. The sun beat warm against the old man's skin which had thinned as the years raced by him. And in that moment he drifted off to sleep.
...
How long had he been out? One hour? Two? It was not yet dusk but the cicadas had begun to roar.
His eyes fluttered half-open, though only one seemed willing to do the work. There was a sourness in the back of his throat, metallic and dry, and for a moment he thought perhaps he had bitten his tongue in his sleep. He pressed a hand to his chest and let it rest there. Jus
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active February 27, 2025 20:09
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@halilim
halilim / zsh-debug-startup.sh
Created August 21, 2014 14:13
List zsh startup scripts line by line verbosely
zsh -x 2>&1
@rauchg
rauchg / README.md
Last active April 13, 2025 04:29
require-from-twitter