Skip to content

Instantly share code, notes, and snippets.

@insin
insin / BootstrapModalMixin.js
Last active February 5, 2021 07:47
A Bootstrap (3) modal mixin for React / MIT License
/** @jsx React.DOM */
var BootstrapModalMixin = function() {
var handlerProps =
['handleShow', 'handleShown', 'handleHide', 'handleHidden']
var bsModalEvents = {
handleShow: 'show.bs.modal'
, handleShown: 'shown.bs.modal'
, handleHide: 'hide.bs.modal'
var cluster = require('cluster');
var PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
cluster.fork();
cluster.fork();
cluster.on('disconnect', function(worker) {
@mikeal
mikeal / install.bash
Last active January 28, 2020 03:39
Find and install latest node from source on Ubuntu.
#!/bin/bash
echo "Finding latest version."
VERSION=`curl -s http://nodejs.org/dist/latest/SHASUMS.txt | awk '/node-v/ {print $2}' | head -1 | sed s/node-v// | sed s/-/\ / | awk '{print $1}'`
echo "Preparing to install node-v$VERSION"
url="http://nodejs.org/dist/v"$VERSION"/node-v"$VERSION".tar.gz"
echo "GET" $url
curl $url | tar -zxf -
@JamieMason
JamieMason / annotated-jshintrc.txt
Created June 13, 2014 10:59
An annotated .jshintrc file, based on the docs at http://jshint.com/docs/options.
{
/**
* Tell JSHint about global variables.
*/
"predef": [
// https://github.com/pivotal/jasmine
"after",
"afterEach",
@tj
tj / routes.js
Created October 15, 2011 00:23
Express routes
var app = require('../app');
console.log();
app.routes.all().forEach(function(route){
console.log(' \033[90m%s \033[36m%s\033[0m', route.method.toUpperCase(), route.path);
});
console.log();
process.exit();
import sys
import csv
import httplib, urllib, base64
def main():
# set the name of your repository, username and password
username = "test"
password = "test"
repo = "test"
// Optional `options. Stuff like retry count, ramp-up, etc.
// should have sane defaults.
var wait = waitforit(options, function (cb) {
// This would be the 'test' function.
// cb(true) when 'it' is done.
});
wait.on('ready', function () {
// Do something because the test condition passed.
@rektide
rektide / writing-code.md
Last active December 15, 2015 13:18
Promises are about Getting Rid of a Phase Distinction - A crude guide to what makes Promises Actually Different than every other tool.

A promise is a value, and values are by definition not machines.

Phase Distinctions, Machines, Higher Order Functions,

Tools for composing systems

In CS: a phase distinction is a boundary code goes through on it's way to being run. We write the prime artifact, "the code," but to run a machine, this code is transformed by machines, often many machines transforming, taking whatever the current code is, making decisions about what that code looks like, what it represents, and outputting a new code closer to the final execution target. This is the compilation pipeline goes go through to get executed on the target machine. Phase distinction is applied to types, as types change as code goes through the pipeline, but in general all aspects of the code are going through phasal distinctions as they become closer to being run.

Higher order functions: composing complexity

Async- the most popular library on the planet for helping to deal with functional programming- is a library dedicated to composing functio

var mongoose = require('mongoose');
mongoose.connect('localhost', 'testing_535');
console.error('mongoose version', mongoose.version);
var OID = mongoose.Types.ObjectId;
var ASchema = new mongoose.Schema({
square: mongoose.Schema.ObjectId
, task: Number
var express = require('./')
, http = require('http')
, https = require('https')
, app = express.createServer();
app.use(express.static(__dirname));
http.createServer(app.handle.bind(app)).listen(3000);
https.create....