Skip to content

Instantly share code, notes, and snippets.

@logicalparadox
logicalparadox / spy.js
Created December 6, 2011 01:18
Tiny javascript spy for testing.
function Spy (fn) {
if (!fn) fn = function() {};
function proxy() {
var args = Array.prototype.slice.call(arguments);
proxy.calls.push(args);
proxy.called = true;
fn.apply(this, args);
}
<html>
<head>
<title>Swarm Javascript Library Specifications</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" charset="utf-8"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
type="text/javascript"
charset="utf-8">
</script>
<script src="../node_modules/mocha/mocha.js"
g6Rib2R5hqhkZXRhY2hlZMOpaGFzaF90eXBlCqNrZXnEIwEgo3phlo0X1sVC5SmzHo525ANQKMrlP86o7Marckb6vhAKp3BheWxvYWTFAvh7ImJvZHkiOnsia2V5Ijp7ImVsZGVzdF9raWQiOiIwMTIwYTM3YTYxOTY4ZDE3ZDZjNTQyZTUyOWIzMWU4ZTc2ZTQwMzUwMjhjYWU1M2ZjZWE4ZWNjNmFiNzI0NmZhYmUxMDBhIiwiaG9zdCI6ImtleWJhc2UuaW8iLCJraWQiOiIwMTIwYTM3YTYxOTY4ZDE3ZDZjNTQyZTUyOWIzMWU4ZTc2ZTQwMzUwMjhjYWU1M2ZjZWE4ZWNjNmFiNzI0NmZhYmUxMDBhIiwidWlkIjoiYjYzZThkZjg2MWJmYzAxYzBiYzM1MWVhOTRkOTRkMTkiLCJ1c2VybmFtZSI6ImxvZ2ljYWxwYXJhZG94In0sInNlcnZpY2UiOnsibmFtZSI6ImdpdGh1YiIsInVzZXJuYW1lIjoibG9naWNhbHBhcmFkb3gifSwidHlwZSI6IndlYl9zZXJ2aWNlX2JpbmRpbmciLCJ2ZXJzaW9uIjoxfSwiY2xpZW50Ijp7Im5hbWUiOiJrZXliYXNlLmlvIGdvIGNsaWVudCIsInZlcnNpb24iOiIxLjAuMTUifSwiY3RpbWUiOjE0NjIzNzczMTYsImV4cGlyZV9pbiI6NTA0NTc2MDAwLCJtZXJrbGVfcm9vdCI6eyJjdGltZSI6MTQ2MjM3NzMwOCwiaGFzaCI6Ijc4NmJhM2EzNWJjZjQ4NDJiNjFmZjljMTI3ZmEyMmE5OGQyYjFmMzAyYjUwNmE3M2EwZDcwZTVhZGUyZmE5MDYwYmQ0YzQxYjU4YjMxMDZjYWFiNjQ2ODA4ZDFlNGZiYjE0NWRiMjRkN2Q5NDk1NTQxNjAyYWZhMGVjZjQ3NDA4Iiwic2Vxbm8iOjQ1Njg2OX0sInByZXYiOiIyYzhiY2UyZGQ1ZmYxY2VhNDc2ZTQ1
#!/bin/bash
function tip { echo -e '\E[37;44m'"\033[1m$1\033[0m"; }
set +h
umask 022
export LFS="/srv/lfs/6.6"
export LC_ALL=POSIX
export LFS_TGT=$(uname -m)-lfs-linux-gnu
export PATH=/tools/bin:/bin:/usr/bin
@logicalparadox
logicalparadox / lib.sh
Created October 15, 2013 02:23 — forked from crabtw/lib.sh
HOST=x86_64-unknown-linux-gnu
#TARGET=mips-unknown-linux-gnu
#CROSS_TOOL=$HOME/tmp/mips-2013.05/bin
#CXX=mips-linux-gnu-g++
#CXXFLAGS="-shared -fPIC -mips32r2 -msoft-float -mabi=32"
#LLCFLAGS="-march=mips -mcpu=mips32r2 -soft-float -mattr=+mips32r2,+o32 -relocation-model=pic -disable-fp-elim -segmented-stacks"
TARGET=arm-unknown-linux-gnueabihf
CROSS_TOOL=$HOME/tmp/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin
extern mod extra;
use extra::json::*;
/*
* This function manages to do absolutely no copying, which is pretty cool.
*
* "What are all those `'r`s?" you ask. Well, they're liftime parameters. They
* indicate how long something lasts (before it's freed). They can't change how
* long something lives for, they only allow you to tell the compiler stuff it
@logicalparadox
logicalparadox / transmute.js
Created September 11, 2013 15:20
Super simple logger using transmute streams.
/*!
* Import transmute
*/
var transmute = require('transmute');
/*!
* Base logger
*/

Automated DevStack deployments on Rackspace with salt-cloud

Preparation

Install salt-master and salt-cloud

These instructions will install salt-master and salt-cloud on recent Ubuntu releases. Consult the SaltStack Installation Documentation should you require instructions for other distributions.

echo deb http://ppa.launchpad.net/saltstack/salt/ubuntu `lsb_release -sc` main | sudo tee /etc/apt/sources.list.d/saltstack.list

Unionize: network superpowers for your docker containers

Unionize lets you connect together docker containers in arbitrarily complex scenarios.

Just check those examples.

LAMP stack with a private network between the MySQL and Apache containers

Let's create two containers, running the web tier and the database tier:

function printStackTrace() {
var callstack = [];
var isCallstackPopulated = false;
try {
i.dont.exist+=0; //doesn't exist- that's the point
} catch(e) {
if (e.stack) { //Firefox
var lines = e.stack.split('\n');
for (var i=0, len=lines.length; i<len; i++) {
if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {