Skip to content

Instantly share code, notes, and snippets.

View vicapow's full-sized avatar

Victor vicapow

View GitHub Profile
#!/usr/bin/env bash
# so that I can just do zookeeper start|status|stop|etc...
ZOOPIDFILE=/usr/local/var/run/zookeeper/data/zookeeper_server.pid /usr/local/Cellar/zookeeper/3.4.3/libexec/bin/zkServer.sh $1 /usr/local/etc/zookeeper/zoo.cfg
@vicapow
vicapow / lock.js
Created July 17, 2012 06:40
locking with zookeeper/zkplus and node.js
var assert = require('assert')
, zookeeper = require('zkplus')
, path = require('path')
var client = zookeeper.createClient({
servers: [{
host: 'localhost'
, port: 2181
}]
});
> !!f
ReferenceError: f is not defined
at repl:1:4
at REPLServer.self.eval (repl.js:111:21)
at Interface.<anonymous> (repl.js:250:12)
at Interface.EventEmitter.emit (events.js:88:17)
at Interface._onLine (readline.js:199:10)
at Interface._line (readline.js:517:8)
at Interface._ttyWrite (readline.js:735:14)
at ReadStream.onkeypress (readline.js:98:10)
var client_opts = {
// These are necessary only if using the client certificate authentication
key : fs.readFileSync('client-key.pem')
, cert : fs.readFileSync('client-cert.pem')
, ca: [ fs.readFileSync('server-cert.pem') ]
, port : port
};
var cleartextStream = tls.connect(client_opts, function() {
1) internal server /send should allow notifications to be posted:
Error: the string "Hostname/IP doesn't match certificate's altnames" was thrown, throw an Error :)
at Runner.fail (/usr/local/lib/node_modules/mocha/lib/runner.js:153:11)
at Runner.uncaught (/usr/local/lib/node_modules/mocha/lib/runner.js:426:8)
at process.uncaught (/usr/local/lib/node_modules/mocha/lib/runner.js:456:10)
at process.EventEmitter.emit (events.js:123:20)
unsigned char red = ((color & 0xE0) >> 5) * (36.42857142857143);
unsigned char green = ((color & 0x1C) >> 2) * (36.42857142857143);
unsigned char blue = (color & 0x03) * 85;
@vicapow
vicapow / gist:4206893
Created December 4, 2012 17:58
mongoose casting object ids of type string to ObjectId()
var mongoose = require('mongoose')
, db = mongoose.createConnection('localhost', 'test')
var CommentSchema = mongoose.Schema({
title : 'string'
})
var PostSchema = mongoose.Schema({
name: 'string'
, comments : [CommentSchema]
USE ocal;
DROP TABLE IF EXISTS openclipart_clipart;
-- FILE
CREATE TABLE openclipart_clipart(
id integer NOT NULL auto_increment,
filename varchar(255),
owner integer NOT NULL,
PRIMARY KEY(id),
var sockets = [...] ; // some array of sockets
for(var i = 0; i < sockets.length; i++){
socket.on( 'CardPick', function(data) {
Draft.cardPick( data, draftId, socket );
// `socket` will always be the last item in `sockets` every time the callback is called on any of the sockets
});
}
* remote origin
Fetch URL: git@github.com:vicapow/test-repo.git
Push URL: git@github.com:vicapow/test-repo.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)