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'; | |
if(process.env.NODE_ENV != 'production') { | |
require('dotenv').config(); | |
} | |
/** | |
* Module Dependencies | |
*/ | |
const | |
Http = require('http'), | |
Mongoose = require('mongoose'), |
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
0xE56a5289757db606C317342eB1F92C23E650443F |
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 node | |
"use strict"; | |
/** | |
* Run as follows: ansible-playbook -i ./vagrant_inventory.js pbook.yml, | |
* NB requires the 'vagrant hostsupdater plugin' | |
*/ | |
//============================================================================= | |
/** | |
* Get list of vagrant hosts | |
*/ |
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
def soln(A): | |
sumA, prevSum, n = sum(A), 0, len(A) | |
for i in xrange(n): | |
rem = sumA - prevSum - A[i] | |
if prevSum == rem: | |
return i | |
else: | |
prevSum += A[i] | |
return -1 |
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
def nqueens(n): | |
#This version generates the first valid soln | |
Q = [None] * n | |
dfs(0, Q) | |
print 'ans =', Q | |
return Q | |
def dfs(r, Q): | |
cand_pos, stk = gen_pos(r, Q), [] |
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
def nqueens(n): | |
#This version generates all possible solns | |
seen = set() | |
for c in xrange(n): | |
Q = [None] * n | |
attempt = dfs(0, c, Q) | |
if attempt: | |
res = '' | |
for val in Q: | |
res += str(val) |
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 dependencies | |
*/ | |
//----------------------------------------------------------------------------- | |
var | |
kue = require('kue'), | |
config = require('../config/config'); | |
//============================================================================= | |
/** | |
*Create 'queue' instance |
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 dependencies | |
*/ | |
//----------------------------------------------------------------------------- | |
var | |
kue = require('kue'), | |
config = require('../config/config'); | |
//============================================================================= | |
/** | |
*Create 'queue' instance |
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 dependencies | |
*/ | |
//----------------------------------------------------------------------------- | |
var client = require('./producers').client; | |
//============================================================================= | |
/** | |
*create job processor instance | |
*/ | |
//----------------------------------------------------------------------------- |
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 dependencies | |
*/ | |
//----------------------------------------------------------------------------- | |
var | |
monq = require('monq'), | |
config = require('../config/config'); | |
//============================================================================= | |
/** | |
*Create monq instance |
NewerOlder