Skip to content

Instantly share code, notes, and snippets.

var http = require('http');
var finishedJobs = [];
http.createServer(function (request, response) {
if(finishedJobs[request.pathname]) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end(finishedJobs[request.pathname].toString());
} else {
response.writeHead(404, {'Content-Type': 'text/plain'});
response.end("Result not found");
@outbounder
outbounder / ClientHelper.java
Created July 7, 2011 13:08
jersey client helper for trusting all certificates in SSL/TLS
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
@outbounder
outbounder / fab.py
Created August 5, 2011 09:54
Execute Fabric task
import fabric.main as fab
from fabric.api import *
def getFabCommand(name):
parts = name.split(".")
p = parts.pop(0)
if p not in fab.commands:
return None
else:
command = fab.commands[p]
var formidable = require("formidable");
var fs = require("fs");
var form = new formidable.IncomingForm(),
files = [],
fields = [];
form.uploadDir = __dirname+"/uploads";
form
.on('field', function(field, value) {
@outbounder
outbounder / test-setup-nodejs.js
Created August 26, 2011 22:04
setup nodejs (git, nvm, npm, forever) on remote machine
// working NodeSSH can be used by installing via npm this http://github.com/outbounder/NodeSSH/tarball/master
var SSHClient = require("NodeSSH");
var Expect = require('node-expect');
var password = "password";
var ssh=new SSHClient("host","root", "rootPassword");
parser = new Expect();
parser.debug = 5;
@outbounder
outbounder / install.sh
Created September 14, 2011 10:30
auto-install nvm, node.js
#!/bin/bash
NODE="v0.4.11"
NVMDIR=~/.nvm
NVM=~/.nvm/nvm.sh
echo "installing projectman-repl"
hash nvm 2>&- || {
echo "couldn't find nvm, sourcing from $NVM"
test -e $NVM || {
echo "couldn't find $NVM -> installing..."
var allCount = items.length;
var handleSave = function(err) {
if(err) {
allCount = 0; // this will prevent sending success: true if invoked again...
res.send({ success: false, msg: err}, 400);
return;
}
allCount -= 1;
if(allCount == 0) {
@outbounder
outbounder / installNodejs.sh
Created July 18, 2012 15:57
install node.js on ubuntu
#!/bin/bash
NODE=$1
NVMDIR=$2
NVM=$NVMDIR/nvm.sh
echo "installing node.js $1"
hash nvm 2>&- || {
echo "couldn't find nvm, checking for $NVM"
test -e $NVM || {
@outbounder
outbounder / bindTo.js
Created December 5, 2012 14:24
Backbone bindTo enchanced
// Generated by CoffeeScript 1.3.1
/*
Backbone.BindTo
Author: Radoslav Stankov
Project site: https://github.com/RStankov/backbone-bind-to
Licensed under the MIT License.
*/