Skip to content

Instantly share code, notes, and snippets.

@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..."
@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;
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 / 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]
@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;
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");