Skip to content

Instantly share code, notes, and snippets.

View anatoliychakkaev's full-sized avatar

Anatoliy Chakkaev anatoliychakkaev

View GitHub Profile
@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 / 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 / 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 / Capfile
Created January 13, 2011 20:47
Capistrano deploy script
load 'deploy' if respond_to?(:namespace) # cap2 differentiator
load 'config/deploy'
@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 / 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