Skip to content

Instantly share code, notes, and snippets.

View look4regev's full-sized avatar
😎
Saving the world

Regev Golan look4regev

😎
Saving the world
View GitHub Profile
@look4regev
look4regev / aws_credentials.py
Created July 15, 2019 06:54
Get aws key and secret from local credentials file
import boto3
def get_local_aws_credentials():
session = boto3.session.Session()
credentials = session.get_credentials().get_frozen_credentials()
return {'access_key': credentials.access_key,
'secret_key': credentials.secret_key,
'region': session.region_name}
@look4regev
look4regev / nginx_cache_outgoing_requests.conf
Created July 2, 2019 07:38
Nginx config to cache outgoing http requests using reverse proxy
server {
server_name openstreetmap-tiles-cacheproxy.mydomain.com;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X_FORWARDED_PROTO http;
proxy_set_header Host $http_host;
add_header X-Cache-Status-Local $upstream_cache_status;
@look4regev
look4regev / zsh_load_profiler.sh
Created June 11, 2019 09:22
Profiler to find the slowest commands happening on shell startup with zsh
brew install moreutils
cd ~
zsh -xv 2>&1 | ts -i "%.s" > zsh_startup.log
sort --field-separator=' ' -r -k1 zsh_startup.log> sorted.log
# Start a new shell
head sorted.log # Will show slowest operation first
@look4regev
look4regev / delete_all_local_rabbitmq_queues
Created December 19, 2018 13:27
Delete all local rabbitmq queues quick cli tool
# deletes all rabbitmq queues locally if they fucked or needs purging
delqueues() {
rabbitmqadmin -f tsv -q list queues name | while read queue; do rabbitmqadmin delete queue name=${queue}; done
}
@look4regev
look4regev / change_all_mongo_dbs_user_password.js
Created October 14, 2018 12:28
Change password of a user found in each db on a MongoDB instance
db.getMongo().getDBNames().forEach(function (dbName) {
if (dbName != "config" && dbName != "local") {
print("Changing Database: " + dbName);
var curr_db = db.getSiblingDB(dbName);
curr_db.changeUserPassword("myuser", "abc123");
}
});
# -*- coding: utf-8 -*-
# main.py
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.security import forget
from pyramid.view import view_config
from pyramid.httpexceptions import HTTPFound
from authomatic import Authomatic
@look4regev
look4regev / basic_mac_setup.sh
Last active July 31, 2019 14:47
Installs basic dev tools for MacOS
#!/bin/bash
echo "Installing brew (MacOS package manager)"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo "Installing needed tools for development"
brew install gcc asdf coreutils gpg zlib mongodb rabbitmq yarn libxmlsec1 git cask zsh pkg-config readline openssl
echo "Install python and node with asdf"
source /usr/local/opt/asdf/asdf.sh
@look4regev
look4regev / list_tools.py
Created December 6, 2017 08:58
python list tools
def interwine_element_into_list(lst, elem):
""" Usage example: ([1,2,3], 0) => [1,0,2,0,3,0] """
res = [item for pair in zip(lst, [elem]*len(lst)) for item in pair]
return res
@look4regev
look4regev / pullall_repos_in_dir_bash
Last active December 19, 2018 13:23
pullall_repos_in_dir_bash
# Put this in your ~/.zshrc to pull all repos in your git repos dir
export GIT_REPOS_DIR="~/complete-here/git"
pullall() {
failed=( )
cd $GIT_REPOS_DIR
for D in */; do cd $D; echo "Pulling $D"; git pull -r || failed+=($D); if [ $(git_current_branch) != 'master' ]; then failed+="($D) not on master"; fi; cd ..; done
cd -
echo "Failed: $failed"
}