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
AvnerCohen / install_poppler.sh
Created Jul 26, 2018
Install popller and pdfparser on Centos 6 / Amazon AMI
View install_poppler.sh
#!/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.
CMAKE_VERSION='3.6.2'
POPPLER_VERSION="poppler-0.67.0"
TARGET_DIR='/opt/poppler'
View random.rb
Random gist with no data.
Testing the alers
View gist:663597c3423f13ad0cb6527573eb24c5
[default]
aws_access_key_id = AKIHONEYPOTHONEYPPKA
aws_secret_access_key = juBYW/RHTE1ki+DyDFG/uPIhtwO9hm9+8+ErzMo9
honeypot = True
@AvnerCohen
AvnerCohen / nginx_install_more_headers.sh
Created Nov 5, 2017
Install nginx with clear_more_headers - Latest Version 1.13.6
View nginx_install_more_headers.sh
yum update -y nginx
yum install -y pcre-devel
service nginx stop
mkdir ~/nginx_test
cd ~/nginx_test/
wget 'http://nginx.org/download/nginx-1.13.6.tar.gz'
tar -xzvf nginx-1.13.6.tar.gz
wget https://github.com/openresty/headers-more-nginx-module/archive/v0.33.tar.gz
tar -xzvf v0.33.tar.gz
cd nginx-1.13.6/
@AvnerCohen
AvnerCohen / install.sh
Last active Oct 12, 2019
Install Erlang + Rabbit MQ on AWS EC2 server
View install.sh
# erlang deps
sudo yum groupinstall "Development Tools"
sudo yum install ncurses-devel openssl-devel
# erlang
wget http://erlang.org/download/otp_src_20.1.tar.gz
tar -zxvf otp_src_20.1.tar.gz
rm -f otp_src_20.1.tar.gz
cd otp_src_20.1/
./configure
@AvnerCohen
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
NEW_VERSION="2.7.14"
CURRENT_VERSION="$(python -V 2>&1)"
if [[ "$CURRENT_VERSION" == "Python $NEW_VERSION" ]]; then
echo "Python $NEW_VERSION already installed, aborting."
else
echo "Starting upgrade from ${CURRENT_VERSION} to ${NEW_VERSION}"
@AvnerCohen
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 = itemsToDel.map(function(item){ return item["_id"]})
if (IDs.length > 0 ) {
db.tasks.remove({"_id": {"$in": IDs } });
sleep(5000);
} else {
COUNTER++;
@AvnerCohen
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(database.name);
cols = db.getCollectionNames().sort();
cols.forEach(function(col) {
if (!db[col]) { return; }
db[col].getIndexes().sort().forEach(function(index) {
if ("_id_" !== index.name) {
print("at database: [" + database.name +"], db." + col + ".ensureIndex(" + tojson(index.key) + ")");
@AvnerCohen
AvnerCohen / git_aliases_setup.sh
Last active Jan 9, 2016
Random Git aliases and commands to
View git_aliases_setup.sh
# 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
AvnerCohen / delete_branches_older_than.sh
Last active Oct 17, 2019 — forked from antonio/delete_branches_older_than.sh
Script to delete branches older than 6 months old, ignore local vs remote errors.
View delete_branches_older_than.sh
#!/bin/sh
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
ECHO=""
fi
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.