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
#!/bin/bash | |
# Print an introduction line in cyan | |
printf "\033[0;36mPre-commit hook - For Checking Tabs in Golang Files...\033[0m \n" | |
# Grab feed of staged files | |
files=$(git diff --name-only --cached -- "*.go") | |
numfiles=$( printf '%s' "$files" | grep -c '^' ) | |
if [ $numfiles -eq 0 ] |
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
# using mongodump | |
mkdir swateek | |
mongodump --db="stats" --out="./swateek" --gzip | |
cd swateek | |
tar cvzf ../db_backup.tar.gz * | |
# using mongorestore | |
tar -xvzf db_backup.tar.gz | |
mongorestore --gzip --db="stats" --noIndexRestore stats/ |
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
# Everything Pymongo |
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
''' | |
https://stackoverflow.com/a/43491315/1844056 | |
''' | |
def keys_exists(element, *keys): | |
''' | |
Check if *keys (nested) exists in `element` (dict). | |
''' | |
if not isinstance(element, dict): | |
raise AttributeError('keys_exists() expects dict as first argument.') |
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
#!/bin/bash | |
help() | |
{ | |
echo "Invalid Arguments Supplied.." | |
echo "############## Use one from below ##############" | |
echo "'./run_db.sh --start' for starting MongoDB server" | |
echo "'./run_db.sh --stop' for stopping MongoDB server" | |
echo "'./run_db.sh --clean' for clean restart of MongoDB server" | |
} |
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/bash | |
echo -ne "[#] 10%\r" | |
sleep 1 | |
echo -ne "[##] 20%\r" | |
sleep 1 | |
echo -ne "[###] 30%\r" | |
sleep 1 | |
echo -ne "[####] 40%\r" | |
sleep 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
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 }'` |