Skip to content

Instantly share code, notes, and snippets.

View eik3's full-sized avatar

Eike Herzbach eik3

View GitHub Profile
@eik3
eik3 / rp.sh
Last active November 7, 2023 09:25
A bash script to update all git repos
#!/usr/bin/env bash
# A script to update all git repositories in a directory tree
# Run `rp status` to see the status of all repositories
# Run `rp update` to update all repositories that are on the main branch and have no uncommitted changes
my_project_dir=/path/to/my/git/repos
function print_status() {
tput bold
@eik3
eik3 / README.md
Last active February 11, 2022 09:48
Git pre-commit and pre-push hooks to avoid accidental main / master branch commits / pushes
  1. Save files to ~/.git/hooks/
  2. Make them executable: chmod +x ~/.git/hooks/pre-{commit,push}
  3. Configure git to use these hooks: git config --global core.hooksPath ~/.git/hooks
k=k$RANDOM
function r {
redis-cli -p 16379 $*
}
count=$1
i=0
while [ $i -lt $count ]; do
sleep .1
let i+=1
#!/bin/bash
init=true
function do_stuff () {
while :; do
echo -n .
sleep .5
done
}
while :; do
if [ "$(nc -l 9999)" = "on" ]; then
@eik3
eik3 / profile_tasks.py
Last active January 11, 2016 23:33
Show Ansible timing stats at end of play
"""
based on
https://github.com/jlafon/ansible-profile
https://github.com/ansible/ansible/blob/devel/lib/ansible/plugins/callback/timer.py
just throw this into a callback_plugins directory inside your playbooks directory
"""
import time
import datetime
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers
// ==UserScript==
// @name WorldTimeBuddy hacks
// @description
// @namespace http://www.worldtimebuddy.com/
// @include http://www.worldtimebuddy.com/*
// @match http://www.worldtimebuddy.com/*
// ==/UserScript==
(window.setTimeout(function(){
document.getElementsByClassName("wrapper")[0].removeChild(document.getElementById("toprek"));
@eik3
eik3 / gist:936362
Created April 22, 2011 09:46
Process Grep Bash Function
function prg {
WIDE=""
if [ "$1" == "-w" ]
then
WIDE="www"
shift
fi
processes=$(pgrep -- "$1")
if [ ! -z "${processes}" ]
$ cat Gemfile
source :rubygems
gem "sinatra"
$ cat config.ru
require 'rubygems'
require 'bundler'
Bundler.require
@eik3
eik3 / block facebook.sh
Created December 20, 2010 16:39
how to prevent your computer from talking to facebook
# use the 127.0.0.2 address of the loopback interface so that it doesn't interfere with other servers on localhost
echo '127.0.0.2 blog.facebook.com static.ak.connect.facebook.com www.facebook.com facebook.com static.ak.fbcdn.net connect.facebook.net creative.ak.facebook.com ads.ak.facebook.com ads.ak.facebook.com.edgesuite.net' | sudo tee -a /etc/hosts
# run a tiny ruby/rack app with unicorn to reply with an empty HTTP 200 response on all requests
sudo unicorn -D -l 127.0.0.2:80 -e 'lambda { |env| [ 200, {"Content-Type" => "text/plain"}, "" ] }'