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 | |
| from numpy.linalg import norm | |
| class Kmeans: | |
| '''Implementing Kmeans algorithm.''' | |
| def __init__(self, n_clusters, max_iter=100, random_state=123): | |
| self.n_clusters = n_clusters | |
| self.max_iter = max_iter |
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/python | |
| import os | |
| import sys | |
| import tarfile | |
| import subprocess | |
| from datetime import datetime | |
| from pymongo import MongoClient | |
| class UpgradeMongo(): |
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/python | |
| import moment | |
| # New York's | |
| ny_now_local = moment.utcnow().timezone("America/New_York") | |
| ny_midnight_local = ny_now_local.clone().replace(hours=0, minutes=0, seconds=0, microseconds=0) | |
| ny_prev_midnight_local = ny_midnight_local.clone().subtract(days=1) | |
| ny_prev_lasthour_local = ny_prev_midnight_local.clone().replace(hours=23, minutes=59, seconds=59, microseconds=999999) |
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
| # Clean unused dockers in repo, which are named as <none> | |
| docker rmi -f `docker images | grep none | awk '{ print $3 }'` | |
| docker rm `docker ps -a | awk '{ print $1 }'` |
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']; }); |