This file contains hidden or 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
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; |
This file contains hidden or 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
/** | |
* Deep diff between two object, using lodash | |
* @param {Object} object Object compared | |
* @param {Object} base Object to compare with | |
* @return {Object} Return a new object who represent the diff | |
*/ | |
function difference(object, base) { | |
function changes(object, base) { | |
return _.transform(object, function(result, value, key) { | |
if (!_.isEqual(value, base[key])) { |
This file contains hidden or 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 bash | |
# fresh-chrome | |
# | |
# Use this script on OS X to launch a new instance of Google Chrome | |
# with its own empty cache, cookies, and user configuration. | |
# | |
# The first time you run this script, it will launch a new Google | |
# Chrome instance with a permanent user-data directory, which you can | |
# customize below. Perform any initial setup you want to keep on every |
This file contains hidden or 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'; | |
const cluster = require('cluster'); | |
const http = require('http'); | |
const numCores = 3; | |
var workerIds = []; | |
if (cluster.isMaster) { | |
console.log(`Master ${process.pid} is running`); |
This file contains hidden or 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 <dbname>; | |
var collectionNames = db.getCollectionNames(), stats = []; | |
collectionNames.forEach(function(n){ | |
stats.push(db[n].stats()); | |
}); | |
stats = stats.sort(function(a, b) { return b['size'] - a['size']; }); |
This file contains hidden or 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 <dbname>; | |
var collectionNames = db.getCollectionNames(), stats = []; | |
collectionNames.forEach(function(n){ | |
stats.push(db[n].stats()); | |
}); | |
stats = stats.sort(function(a, b) { return b['size'] - a['size']; }); |
This file contains hidden or 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
var params = {}; | |
var filter = {}; | |
params['filterField'] = "field1,field2"; | |
params['filterData'] = "2,3;abc,cde"; | |
if(params.hasOwnProperty('filterField') && params.hasOwnProperty('filterData')){ | |
var filterFieldArr = params.filterField.split(','); | |
var filterDataArr = params.filterData.split(';'); |
This file contains hidden or 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
from datetime import datetime | |
import time | |
def task(): | |
print "This is my task at - " + str(datetime.now()) | |
while True: | |
task() | |
time.sleep(5) |
This file contains hidden or 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
// export data to csv | |
print("ap_mac,tags"); | |
db.managedaps.find({}).forEach(function(ap){ | |
print(ap.mac+","+ap.tags); | |
}); | |
// mongo dbname filename.js > out.csv |
This file contains hidden or 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
import numpy as np | |
import matplotlib.pyplot as plt | |
hist, bin_edges = np.histogram([1, 1, 2, 2, 2, 2, 3], bins = range(5)) | |
plt.bar(bin_edges[:-1], hist, width = 1) | |
plt.xlim(min(bin_edges), max(bin_edges)) | |
plt.show() |