Skip to content

Instantly share code, notes, and snippets.

View rbeer's full-sized avatar

Raphael Beer rbeer

  • Berlin, Germany
View GitHub Profile
@rbeer
rbeer / .git_aliases.sh
Last active April 25, 2022 14:28
Handy aliases for your everyday git workflow
### Install
# 1. Download this file to ~/.git_aliases
# 2. Add `source ~/.git_aliases` to your ~/.bash_aliases or ~/.bashrc file
###
# git
# These aliases follow a simple scheme of 'git' and then
# the first letters of the command and its options.
# There are a few exceptions, like `gitaa` which means
# git add (all), i.e. `git add .`
@rbeer
rbeer / lessls.sh
Created May 3, 2018 09:00
Less-ls; ls for directories, less for files - in one single `ls` alias
#!/bin/bash
LS_PATH=$1
function lsFallback() {
/bin/ls -alh --color=auto $LS_PATH
exit $?
}
if [ "$LS_PATH" == "" ]; then lsFallback; fi
@rbeer
rbeer / README.md
Last active October 18, 2017 13:47
Saint Lague / Schepers committee seat distribution

Webster/Sainte-Laguë/Schepers method

https://en.m.wikipedia.org/wiki/Webster/Sainte-Laguë_method

Calculates seat distribution of a committee, using the Webster/Sainte-Laguë/Schepers method for seat allocation.

It takes a number of seats in the committee and a set of parties with their number of seats in the actual parliament.

@rbeer
rbeer / diff-repos.sh
Last active July 14, 2017 20:58
Diff working-tree of two git repositories, testing multiple branches
#! /usr/bin/env bash
_V="0.0.1"
function print_usage() {
printf '=%.0s' {1..80}; printf '\n'
echo "Diff Repos - $_V"
echo "Diff working-tree of two git repositories, testing multiple branches"
echo "Depends: ./diff-branches, write-access to ./"
echo "Usage: ./diff-repos.sh <repository_1> <repository_2> [-v]"
@rbeer
rbeer / openssh-rdm.md
Last active May 20, 2017 22:12
ssh -L example

$ ssh yourhost.com -L 7000:localhost:6379

 -----                         ----------------                          -----------------                         --------------
| RDM | -- localhost:7000 --> | OpenSSH, `ssh` | -- yourhost.com:22 --> | OpenSSH, `sshd` | -- localhost:6379 --> | redis-server |
 -----                         ----------------                          -----------------                         --------------
                (1)                                       (2)                                        (3)
@rbeer
rbeer / ..ps1rc
Last active April 25, 2022 14:17
PS1 Themes
### NOTE
Remove the first `.` from this file's name. Two `..` are necessary to name this gist correctly.
###
# [44/48]
# PS1Themes - v0.1.0
# Author: Raphael Beer <raphael.beer@protonmail.com>
# Dependencies:
# - bash
# - tput
@rbeer
rbeer / chrometd.sh
Created January 6, 2017 01:51
chrome-tab-doctor
#!/usr/bin/env bash
# exit codes:
# - 0: ok
# - 1: unknown (fatal)
# - 2: no window found (fatal)
# $1 = key (sequence) to send
# allows + operand for concatenation, e.g. ctrl+e, alt+h
# use space for separation, e.g. "f o o"
@rbeer
rbeer / colors.sh
Created January 5, 2017 00:45
List bash colors in terminal
#!/bin/bash
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# http://sam.zoy.org/wtfpl/COPYING for more details.
for fgbg in 38 48 ; do #Foreground/Background
for color in {0..256} ; do #Colors
@rbeer
rbeer / snarpshooter.sh
Last active January 23, 2022 06:04
Sna[r]pshooter - Take screenshots of specific windows
#!/usr/bin/env bash
C_RED="\e[91m"
C_RESET="\e[0m"
function print_help {
echo "sna[r]pshooter - 1.0.0"
echo "Takes screenshot of a selected window, the whole screen or a selected region."
echo -e "Depends: ImageMagick's 'import', 'xwininfo'\n"
if [ -n "$1" ]; then
@rbeer
rbeer / gitup.sh
Created April 28, 2016 01:25
simple repo updater
#! /bin/env bash
# `gitup.repos` is a text file
# with one absolute path per line
if [ ! -e ./gitup.repos ]; then
echo "No repo list (gitup.repos) found!"
exit 1;
fi