This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on http://www.diveintojavascript.com/projects/sprintf-for-javascript | |
String.prototype.format = function() { | |
var i = 0, a, f = this, o = [], m, p, c, x, s = ''; | |
while (f) { | |
if (m = /^[^\x25]+/.exec(f)) { | |
o.push(m[0]); | |
} | |
else if (m = /^\x25{2}/.exec(f)) { | |
o.push('%'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var amqp = require('./amqp'), | |
sys = require('sys'), | |
net = require('net'), | |
events = require('events'); | |
var RabbitClient = function() { | |
events.EventEmitter.call(this); | |
var self = this; | |
var connection = amqp.createConnection({ host: cfg.AMQP.Host }); | |
connection.addListener('ready', function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: nginx | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the nginx web server | |
# Description: starts nginx using start-stop-daemon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'), | |
assert = require('assert'), | |
crypto = require('crypto'); | |
var msg = "Gaur!"; | |
fs.readFile('PrivateKey.pem', 'utf-8', function(e,pri) { | |
var signer = crypto.createSign('sha256').update(msg); | |
var signature = signer.sign(pri, output_format='base64'); | |
fs.readFile('PublicKey.pem', 'utf-8', function(e,pub) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys'), | |
spawn = require('child_process').spawn, | |
openssl = spawn('python', ['test.py']); | |
openssl.stdout.on('data', function (data) {+ | |
sys.print('signature is valid: ' + data); | |
}); | |
openssl.stderr.on('data', function (data) { | |
sys.print('Error: ' + data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var EventBus = function() { | |
var events = []; | |
var p_on = function(eventName, callback) { | |
if (!events.some(function(e) { | |
return e.name == eventName; })) { | |
var new_event = { | |
name: eventName, | |
cb: callback | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_.mixin({ | |
format: function(string) { | |
var i = 1, a, f = string, o = [], m, p, c, x, s = ''; | |
while (f) { | |
if (m = /^[^\x25]+/.exec(f)) { | |
o.push(m[0]); | |
} | |
else if (m = /^\x25{2}/.exec(f)) { | |
o.push('%'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
import sys, getopt, subprocess, os | |
help_message = ''' | |
Usage: deploy_all | |
\t-s server_name | |
\t-c couchapp exec''' | |
class Usage(Exception): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(socketio_transport_xhr_polling). | |
-include_lib("../include/socketio.hrl"). | |
-behaviour(gen_server). | |
%% API | |
-export([start_link/2]). | |
%% gen_server callbacks | |
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, | |
terminate/2, code_change/3]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
handle_cast(listen, #state{socket=Socket, rest=Rest} = State) -> | |
case gen_tcp:recv(Socket, 0, 35000) of | |
{ok, Data} -> | |
RestOfData = parse(<<Rest/binary, Data/binary>>), | |
gen_server:cast(?SERVER, listen), | |
State#state{rest=RestOfData}; | |
{error, closed} -> | |
io:format("error, socket closed, do failover? ~n"), | |
gen_server:cast(?SERVER, connect), | |
failover(State); |
OlderNewer