Skip to content

Instantly share code, notes, and snippets.

@outbounder
outbounder / cell.json
Created June 30, 2014 12:00
angelscripts cellcmds cell.json
{
"remote": "user@11.222.333.444",
"cwd": "~/app",
"source": "git@app.git",
"origin": "origin",
"branch": "develop",
"nvmPath": "~/.nvm/nvm.sh",
"nodeVersion": "v0.10.24",
"start": "forever --sourceDir /home/app -a -l /home/app/app.js.out --minUptime 5000 --spinSleepTime 2000 start app.js",
"stop": "forever stop app.js",
@outbounder
outbounder / mongodb-sync.js
Created December 8, 2014 10:19
mongodb-sync.js
/**
* Usage: $ node mongodb-sync.js <user>@<ip> <database-name>
**/
require("shelljs/global")
// prepare remote db
var remote_commands = [
"mongodump --db "+process.argv[3]+" --out /tmp/mongodump-sync",
"tar -zcvf /tmp/mongodump-sync.tar.gz /tmp/mongodump-sync"
]
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 / 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.
*/