How to Git for Beginners

A best-practice model for using git:

Merge a development branch with master:

git checkout master
git pull origin master
git merge test
git push origin master

Simple rebase with conflict resolution

git checkout experiment
git rebase master

If there is a conflict at this time git will show an error and mark conflicting code in your source code. Resolve it and then continue, make sure you delete all the markers as well.

git rebase --continue

Bring an experimental branch up-to-date in comparison to the root branch

# in a secondary branch:
# as if work in the secondary branch had started on top of the changes made to the root branch in the meantime
git pull --rebase
# or
git checkout <root-branch>
git pull
git checkout <experiment-branch>
git rebase <root-branch>
# for example git rebase stage
# If there are conflicts you can either resolve them manually or use 
git checkout --ours foo/bar.js
# to take the experiment version use --theirs, for the root-branch version use --ours
# see
# finally add any changes
git add .
# before you run
git rebase --continue

change to a previous commit

# change to a previous commit
# find the commit id
git log
# revert to that commit id
git reset --hard commit_sha

Apply hotfixes:

checkout master, then do

git cherry-pick <COMMIT_HASH>

if you merge the whole branch later on git will only apply the commits that weren’t already in master that’s a pretty cool way to apply urgent patches.

git merge origin/master

or create a pull request on github, have somebody review / accept it.

cherry pick files (or commits) from another branch

git fetch
git checkout someotherbranch
git pull
git checkout workingbranch
git checkout someotherbranch folder/

amend last comit that is already pushed

Watch out if others have referred to the previous commit they are in serious trouble afterwards

git commit --amend
git push -f


Watch out: In a git repo, only the commit id of a submodule is tracked.

Add a submodule:

git submodule add filepath
git submodule init

Updating all submodules in a repo

git pull && git submodule init && git submodule update && git submodule status
git commit -a

already pushed to remote and want to squash commits?

git rebase -i <commit-id-of-first-commit-you-want-to-squash>

make sure to replace pick by ‘squash’ for all but the first commit in the list that git will show you.

Colorful bash in Debian

# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)


# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] \
        && type -P dircolors >/dev/null \
        && match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
        # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
        if type -P dircolors >/dev/null ; then
                if [[ -f ~/.dir_colors ]] ; then
                        eval $(dircolors -b ~/.dir_colors)
                elif [[ -f /etc/DIR_COLORS ]] ; then
                        eval $(dircolors -b /etc/DIR_COLORS)

        if [[ ${EUID} == 0 ]] ; then
                PS1='${debian_chroot:+($debian_chroot)}\[&#92;&#48;33[01;31m\]\h\[&#92;&#48;33[01;34m\] \W \$\[&#92;&#48;33[00m\] '
                PS1='${debian_chroot:+($debian_chroot)}\[&#92;&#48;33[01;32m\]\u@\h\[&#92;&#48;33[01;34m\] \w \$\[&#92;&#48;33[00m\] '

        alias ls='ls --color=auto'
        alias grep='grep --colour=auto'
        if [[ ${EUID} == 0 ]] ; then
                # show root@ when we don't have colors
                PS1='\u@\h \W \$ '
                PS1='\u@\h \w \$ '

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#    PROMPT_COMMAND='echo -ne "&#92;&#48;33]0;${USER}@${HOSTNAME}: ${PWD}&#92;&#48;07"'
#    ;;
#    ;;

# enable bash completion in interactive shells
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
    . /etc/bash_completion

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found ]; then
    function command_not_found_handle {
            # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
           /usr/bin/python /usr/lib/command-not-found -- $1
                   return $?
                elif [ -x /usr/share/command-not-found ]; then
           /usr/bin/python /usr/share/command-not-found -- $1
                   return $?
           return 127


Python: Beginner Learnings

This builds the requirements.txt. Should contain version of the package (=pinned)

pip freeze | grep paketname >> requirements.txt

in the requirements.txt git repos can be included like this:
git+git::// googletools


Ctrl+Click on Function leads directly to the function location
Ctrl+E shows the last open files for quick going back

Wrapper Class:

class SSWrapper(object):

    ss_instance = None

    def __init__(self, ss_instance):
        self.ss_instance = ss_instance

    def get_worksheet_by_id(id):
        for x in self.ss_instance.asdfasd

   ss = gspread.blah()
   wrapper = SSWrapper(ss)


Pass Code:

class Worksheet(gspread.Worksheet):

DNS Tricks

Get all DNS entries

This gives all DNS entries for a zone in a nice list:

dig axfr 

Reverse DNS – Reverse Delegation


| Welchen Namen soll ich verwenden?:
Diese Entscheidung ist prinzipiell Ihnen überlassen, wichtig ist von technischer Seite nur, dass der Name schon auf Ihre IP-Adresse verweist (“Wird die IP angezeigt, wenn ich den Namen anpinge?”). Typische Beispiele sind oder auch Nur den Domainnamen (“”) alleine sollten Sie nicht verwenden, da manche Mailserver dies fälschlich ebenfalls als Indiz für eine Spamquelle sehen.

| Ich nutze mehrere Domains. Würden die anderen bei einer Änderung nicht weiterhin das gleiche Problem haben?: Nein, es geht lediglich darum, dass die Auflösung an sich stimmig ist (die IP-Reverse zeigt auf einen Namen und dieser Name auf die gleiche IP); der Name muss nicht zur jew. Domain passen.

| Wie sollte ich es nicht machen?:
Gelegentlich nutzen einige User (besonders beim Betrieb von IRC-Bouncern) besonders “lustige” oder “coole” Hostnamen (ich.habe.den.laengesten.hostnamen.der.welt.irc-ist-ganz-grossartig.tld). Für solche, mit Verlaub, “Kindereien” werden allerdings die IP-Adressen vom RIPE nicht vergeben, so dass man davon Abstand nehmen sollte.

| Warum kann ich diese Einträge nicht auf meinem Nameserver machen?:
Für IP-Adressen aus unserem Bereich sind unsere Nameserver als zuständig eingetragen. Eine Weiterleitung Ihres Adressbereiches auf andere Server bieten wir nicht an, zumal sich Reverse-Einträge sehr selten ändern sollten und die Nachteile die Vorteile diese Vorgehens überwiegen würden.

The Coder’s 12 Commandments

  1. Don’t create frameworks, YAGNI
  2. Use methodologies to support you, not to control you
  3. Read Code Complete and The Mythical Man Month
  4. Hire brilliant people
  5. Documentation is fiction, code is fact
  6. Can’t code => No decision power
  7. Testing rocks, debugging sucks. We are on good track on this
  8. Nine women can’t make a baby in one month
  9. Feed your developers good food
  10. Code reviews are important, we should to them
  11. Collect application data to decide about its performance
  12. Share knowledge, everything should be (internally) accessible to everyone

Some stuff that proofed to work while switching VPS to a new kernel for debian wheezy

First of all as root, create some users and give them sudo:
adduser sudo

from your local machine, use password-less ssh:

cat .ssh/ | ssh user@host 'cat >> .ssh/authorized_keys'

Mounting old file system per ssh in the new one:

sudo apt-get install sshfs
makedir /old
sshfs username@ipaddress:/remotepath /old

Apt Sources list:

cp /old/etc/apt/sources.list /etc/apt/sources.list
apt-get update
apt-get dist-upgrade

Why am I getting this on a new system?

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

Add this to /etc/profile

export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

And we also add a nice shortcut for recursive full text searches:

f(){ find . -type f -exec grep -nr $1 {} + ; }

Use like this: f searchterm

Install some packages (apt-get install):

dovecot-mysql dovecot-antispam dovecot-sieve dovecot-pop3d dovecot-managesieved dovecot-imapd
postfix postfix-mysql

Shuffle some files around:

cp -r /old/var/www/* /var/www/
cp -r /var/cache/torrentflux/macolo/
cp -r /old/srv /srv

cp -r /old/usr/share/tead/ /usr/share/tead
cp -r /old/usr/share/yii/ /usr/share/yii
  • Move certs from /etc/ssl and /etc/ssl/private


mysqldump -u root -p --all-databases > /root/mysqldump.sql
mysql -u root -p < /old/root/mysqldump.sql

Dont forget to udate debian-sys-maintainer password from /etc/mysql/debian.cnf and rerun dpkg-reconfigure phpmyadmin

/etc/init.d/mysql restart

Replace some IPs in /etc/bind/

find . -name "*.db" -print | xargs sed -i 's/'

Update some config files:


Don’t forget to install the spam plugins:

apt-get install pyzor
apt-get install razor

Online Marketing Tools & Agencies

SEM Rush: Some top-level stats about sites.
Test Room: SEO Agency with 3000+ high-quality domain farm
Marketo: CRM, lead optimization
Custora: Customer Lifetime Value Optimization : CRM Product Feed Sanitization Raw Google Analytics Data backup Behavioural Targeting, CRO & Web Analytics
adstage – Facebook, Bing, Adwords campaign roll-out tool
meteolytics – Weather Analytics und Forecasts für einzelne REgionen / Städte global SEO/SEM keyword insights (search volume, CPC, etc.)’s dashboard, can integrate various data sources Backlink Explorer – Who linked to your site?

BI Datenaufbereitung:

e-mail Addresses: cebus, schober

Deutschland: – User Experience

London, San Francisco, Ann Arbor, Paris, Milan and Madrid:

Texting: International multi-language texting

iPad – Movies, Songs greyed out?

This did the trick for me:

1. Download and install iExplorer

2. Plug in device first, then open iExplorer

3. Delete the iPhone\Media\iTunes_Control folder (you may want to copy this, just in case)

4. Restart the iPhone / iPad

5. Start iTunes. Not restore iPhone from back up, select New iPhone (don’t worry, you will not lost apps or data on your iPhone doing this)

6. Add music manually with iTunes


Solution by:

Create a bootable Ubuntu USB stick on Mac OS X – so easy

This is really all there is:

1. Download an Ubunto .iso from
2. Plug the USB stick into your mac os x system
3. open a terminal and type: diskutil list
4. unmount your usb stick: i.e. diskutil unmountDisk /dev/disk1
5. copy the content of the iso onto your usb stick: sudo dd if=~/Downloads/ubuntu.iso of=/dev/disk1 bs=1m
6. unload your usb stick: diskutil eject /dev/disk1
7. you’re ready!

Source and more: