Skip to content

Instantly share code, notes, and snippets.

@dachev
dachev / measurable.js
Created June 8, 2011 04:47
Is Measurable
// Actually, this is not going to work. Please ignore it.
function isMeasurable(target, array) {
if (array.length < 1) { return false; }
if (array.indexOf(target) >= 0) { return true; }
var weights = array.concat(target);
var length = 1 << weights.length;
for (var i = 0; i < length; i++) {
require('./module')
console.log(test);
@dachev
dachev / forever_crontab_reboot_example.js
Created January 3, 2011 03:05
Reboot example with forever
crontab.load(function(err, tab) {
require('npm').load(function (err, npm) {
if (err) { console.log(err); process.exit(1); }
var path = require('path');
var util = require('util');
var uuid = '322ed3d0-6869-11e1-b86c-0800200c9a66';
var npmPrefix = npm.config.get('prefix');
var npmBinRoot = path.join(npmPrefix, 'bin');
var nodePath = process.execPath.split('/').slice(0, -1).join('/');
@dachev
dachev / simple_crontab_reboot_example.js
Created January 3, 2011 03:02
Simple reboot example
require('crontab').load(cronLoaded);
function cronLoaded(err, tab) {
if (err) { console.log(err); process.exit(1); }
var command = '/usr/bin/env echo "starting some service..."';
tab.remove(tab.findCommand(command));
var item = tab.create(command);
item.everyReboot();