Skip to content

Instantly share code, notes, and snippets.

View anatoliychakkaev's full-sized avatar

Anatoliy Chakkaev anatoliychakkaev

View GitHub Profile
@anatoliychakkaev
anatoliychakkaev / Install nodejs
Created December 16, 2010 21:36
Install nodejs shell script
#!/bin/bash
NODE_VERSION=0.3.1
NODE_FILE=node-v$NODE_VERSION
MY_USER=anatoliy
REDIS_VERSION=2.0.3
apt-get update
apt-get install -y build-essential git-core nginx libssl-dev pkg-config
wget http://nodejs.org/dist/$NODE_FILE.tar.gz
@anatoliychakkaev
anatoliychakkaev / spec_helper.js
Created December 25, 2010 14:44
nodeunit spec helper file
var group_name = false, EXT_EXP;
function it(should, test_case) {
check_external_exports();
if (group_name) {
EXT_EXP[group_name][should] = test_case;
} else {
EXT_EXP[should] = test_case;
}
}
@anatoliychakkaev
anatoliychakkaev / Capfile
Created January 13, 2011 20:47
Capistrano deploy script
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'config/deploy'
@anatoliychakkaev
anatoliychakkaev / demo.js
Created January 12, 2012 08:32
Require in runInNewContext
var Module = require('module');
var vm = require('vm');
var path = require('path');
var filename = process.cwd() + '/lib/eval.js';
var mod = new Module(filename);
var context = {
module: mod,
__filename: filename,
@anatoliychakkaev
anatoliychakkaev / stopSOPA-middleware-example.js
Created January 17, 2012 23:07
Blackout middleware for express, railwayjs
app.use(function blackoutMiddleware(req, res) {
// obtain static html here: http://www.zachstronaut.com/lab/text-shadow-box/stop-sopa.html
// or here: https://raw.github.com/zachstronaut/stop-sopa/master/index.html
fs.readFile('./public/stopSOPA.html', function (err, file) {
res.send(file.toString(), 503);
});
});
@anatoliychakkaev
anatoliychakkaev / db-tools.js
Created March 15, 2012 16:07
RailwayJS database tools
exports.init = function () {
railway.tools.database = function db() {
var action = process.argv[3];
switch (action) {
case 'migrate':
case 'update':
perform(action, process.exit);
break;
default:
console.log('Unknown action', action);
@anatoliychakkaev
anatoliychakkaev / server.js
Created July 31, 2012 06:00 — forked from jeffrafter/server.js
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
@anatoliychakkaev
anatoliychakkaev / benchmark.js
Created October 12, 2012 12:54
Benchmark sample
var score = 0;
var started = 0;
var http = require('http');
require('./server');
function request(params, callback) {
var req = new http.IncomingMessage;
req.headers = {host: params.host};
req.url = params.path;
@anatoliychakkaev
anatoliychakkaev / benchmark.js
Created October 18, 2012 14:35
Jugglingdb benchmark
var limit = 10;
var success = 0;
var Schema = require('./').Schema;
var AC = require('./').AbstractClass;
var s = new Schema('redis2', {});
var util = require('util');
s.setMaxListeners(100);
var Model = s.define('Model', {
@anatoliychakkaev
anatoliychakkaev / gist:4353750
Created December 21, 2012 16:13
Git summary for compoundjs, 21 dec 2012
project: compound
commits: 735
files : 105
authors:
594 Anatoliy Chakkaev 80.8%
41 Sascha Gehlich 5.6%
24 1602 3.3%
11 Uli 1.5%
10 Taliesin Sisson 1.4%
6 Dale Tan 0.8%