Skip to content

Instantly share code, notes, and snippets.

Avner Cohen AvnerCohen

Block or report user

Report or block AvnerCohen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
AvnerCohen /
Created Jul 26, 2018
Install popller and pdfparser on Centos 6 / Amazon AMI
#!/bin/bash -e
set -x
# Poppler is used by resume parser for a faster PDF data extraction.
# Deploy is a bit man ual and complicated because of the C libs involved
# the fact no pip is used (anaconda and not virtualenev) and that the
# Cmake version eeds to be be udpated as part of it.
View random.rb
Random gist with no data.
Testing the alers
View gist:663597c3423f13ad0cb6527573eb24c5
aws_access_key_id = AKIHONEYPOTHONEYPPKA
aws_secret_access_key = juBYW/RHTE1ki+DyDFG/uPIhtwO9hm9+8+ErzMo9
honeypot = True
AvnerCohen /
Created Nov 5, 2017
Install nginx with clear_more_headers - Latest Version 1.13.6
yum update -y nginx
yum install -y pcre-devel
service nginx stop
mkdir ~/nginx_test
cd ~/nginx_test/
wget ''
tar -xzvf nginx-1.13.6.tar.gz
tar -xzvf v0.33.tar.gz
cd nginx-1.13.6/
AvnerCohen /
Last active Oct 12, 2019
Install Erlang + Rabbit MQ on AWS EC2 server
# erlang deps
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel openssl-devel
# erlang
tar -zxvf otp_src_20.1.tar.gz
rm -f otp_src_20.1.tar.gz
cd otp_src_20.1/
AvnerCohen / python2.7.xx.bash
Last active Oct 25, 2018
Updated Python 2.7.xx on an Amazon AMI + make it default (in alternatives) and symlik pip ad virtualenv for future usage
View python2.7.xx.bash
#!/usr/bin/env bash
CURRENT_VERSION="$(python -V 2>&1)"
if [[ "$CURRENT_VERSION" == "Python $NEW_VERSION" ]]; then
echo "Python $NEW_VERSION already installed, aborting."
echo "Starting upgrade from ${CURRENT_VERSION} to ${NEW_VERSION}"
AvnerCohen / delete_celery.js
Last active Oct 30, 2016
Mongo Query to Delete Celery succesfull entries on a large collection, slowly but surely.
View delete_celery.js
var COUNTER = 900;
function deleteSome(count) {
var itemsToDel = db.tasks.find({status: "SUCCESS"}, {_id: 1}).sort({created_at: 1}).limit(count).toArray();
var IDs ={ return item["_id"]})
if (IDs.length > 0 ) {
db.tasks.remove({"_id": {"$in": IDs } });
} else {
AvnerCohen / get_all_database_indexes_from_mongo.js
Created Feb 22, 2016
A script to print out all the indexes in all database of mongo
View get_all_database_indexes_from_mongo.js
var db = db.getSiblingDB("admin");
var dbs = db.runCommand({ "listDatabases": 1 }).databases.sort();
dbs.forEach(function(database) {
db = db.getSiblingDB(;
cols = db.getCollectionNames().sort();
cols.forEach(function(col) {
if (!db[col]) { return; }
db[col].getIndexes().sort().forEach(function(index) {
if ("_id_" !== {
print("at database: [" + +"], db." + col + ".ensureIndex(" + tojson(index.key) + ")");
AvnerCohen /
Last active Jan 9, 2016
Random Git aliases and commands to
# Command: GLOG
# Description: alias that creates a nice and easy on eye history log with graph indication of merge commits and branches
git config --global alias.glog "\!git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative ; true"
# Run:
git glog
# Command: LASTWORKS
# Description: Lists the last 10 branches you worked on
git config --global alias.lastworks "for-each-ref --count=10 --sort=-committerdate refs/heads/"
AvnerCohen /
Last active Oct 17, 2019 — forked from antonio/
Script to delete branches older than 6 months old, ignore local vs remote errors.
ECHO='echo '
for branch in $(git branch -a | sed 's/^\s*//' | sed 's/^remotes\///' | grep -v 'master$'); do
if [[ "$(git log $branch --since "6 months ago" | wc -l)" -eq 0 ]]; then
if [[ "$DRY_RUN" = "false" ]]; then
local_branch_name=$(echo "$branch" | sed 's/remotes\/origin\///')
$ECHO git branch -d $local_branch_name
You can’t perform that action at this time.