Skip to content

Instantly share code, notes, and snippets.

@domenic
domenic / promises.md
Last active November 4, 2025 20:27
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.

In other words, the following asynchronous code:

var d = Domain.create()

d.on("error", function (error) {
    console.error("Error with the twitterverse:", error)
})

d.enter()
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
@mrkline
mrkline / nix_on_windows.md
Last active November 4, 2020 20:36
An overview of setting up *nix tools on Windows using MSYS

*nix on Windows

Options

If you would like to use *nix tools on Windows, you have two main options:

  • Cygwin offers your typical Linux toolset (bash, ls, cd, grep, and the other core utilities) and a DLL that provides some Linux system emulation (signals, etc.). However, Cygwin tends to take the "everything but the kitchen sink" approach, so I generally prefer the second option, MSYS.
@amberj
amberj / setup-local-replit.sh
Created March 14, 2013 23:30
A bash script to automate the installation/setup of repl.it on local system.
#!/bin/bash
#
## @file setup-local-replit.sh
## @author Amber Jain
## @section DESCRIPTION A bash script to automate the installation/setup of repl.it on local system
## @section LICENSE ISC
#################
# Documentation #
@joshuaboshi
joshuaboshi / gist:5362900
Created April 11, 2013 12:13
Python PLY: Yacc definition for IF/ELSE-IF/ELSE nesting
def p_block_if_statement(t):
'''block_if_statement : RULE_OPEN IF data RULE_CLOSE statements else_blocks'''
t[0] = _AstNode(Interpreter.r_if, t[3], t[5], t[6])
def p_else_if_blocks(t):
'''else_blocks : else_if_block
| else_block
| RULE_OPEN END RULE_CLOSE'''
t[0] = t[1]
@vodik
vodik / SOS.md
Last active April 9, 2025 18:21
_Never_ -Sy when installing!

Once upon a time there was a user that wanted to install firefox.

The user tried to do pacman -S firefox but it didn't work. The all mighty pacman reported that firefox-3.2.4-1.i686.pkg.tar.gz could not be found on his mirror. So the user tried pacman -Sy firefox. It worked and the user rejoiced since he could once again go and troll /h/.

But all was not good. The user had made a grave error!

See, when the user told the almighty pacman to -Sy firefox, pacman did

@willurd
willurd / web-servers.md
Last active November 10, 2025 16:13
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@bodokaiser
bodokaiser / v8_object.cc
Created June 7, 2013 19:15
Example of a v8 object exported with node-gyp.
#include "v8.h"
#include "node.h"
using namespace v8;
Handle<Value> Get(const Arguments &args);
Handle<Value> Set(const Arguments &args);
void
Initialize(Handle<Object> exports) {
@tedmiston
tedmiston / nodejs-tcp-example.js
Last active April 1, 2025 08:06
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');