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)
fi

use_color=false

# 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
match_lhs=""
[[ -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)
                fi
        fi

        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\] '
        else
                PS1='${debian_chroot:+($debian_chroot)}\[&#92;&#48;33[01;32m\]\u@\h\[&#92;&#48;33[01;34m\] \w \$\[&#92;&#48;33[00m\] '
        fi

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

# 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
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne "&#92;&#48;33]0;${USER}@${HOSTNAME}: ${PWD}&#92;&#48;07"'
#    ;;
#*)
#    ;;
#esac

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

# 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 $?
        else
           return 127
        fi
    }
fi

from http://jbs.io/article/enabling-colorful-bash-debian-squeeze

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:://pypi.example.ch/simple googletools

pyCharm:

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)
   wrapper.ss_instance.sfsef 

   wrapper.get_worksheet_by_id(id)

Pass Code:

class Worksheet(gspread.Worksheet):
   pass

DNS Tricks

Get all DNS entries

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

dig @ns3.wuk-server.com cvcube.ch axfr 

Reverse DNS – Reverse Delegation

von http://faq.hosteurope.de/view.php?mode=drucken&content_id=4681

| 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 www.nureinbeispiel.de oder auch mail.nureinbeispiel.de. Nur den Domainnamen (“nureinbeispiel.de”) 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/id_rsa.pub | 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):

rsyslog
torrentflux
phpmyadmin
dovecot-core
dovecot-mysql dovecot-antispam dovecot-sieve dovecot-pop3d dovecot-managesieved dovecot-imapd
clamsmtp
postfix postfix-mysql
spamassassin
graphicsmagick
graphicsmagick-imagemagick-compat
netcat

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

Database:

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/46.163.72.202/5.35.241.114/g'

Update some config files:

/etc/postfix/master.cf
/etc/postfix/main.cf
/etc/dovecot/conf.d/...
/etc/spamassassin/local.cf
/etc/clamsmtpd.conf
/etc/apache/sites-available
/etc/bind/...

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 https://www.custora.com/
maximizer.com : CRM
http://www.products-up.com/: Product Feed Sanitization
http://www.clickstreamr.com/ Raw Google Analytics Data backup
http://newelements.de/ Behavioural Targeting, CRO & Web Analytics
adstage – Facebook, Bing, Adwords campaign roll-out tool
meteolytics – Weather Analytics und Forecasts für einzelne REgionen / Städte
http://getstat.com/ global SEO/SEM keyword insights (search volume, CPC, etc.)
trakkboard.com trakken.de’s dashboard, can integrate various data sources
http://explorer.cognitiveseo.com/ Backlink Explorer – Who linked to your site?

BI Datenaufbereitung: http://www.gooddata.com/

e-mail Addresses: cebus, schober
Agencies

Schweiz: www.webrepublic.ch
Europa: hurra.com
Japan: http://www.enigmo.co.jp/en/
London: http://www.equimedia.co.uk/
Deutschland: http://www.eresult.de/ – User Experience

London, San Francisco, Ann Arbor, Paris, Milan and Madrid: http://www.esearchvision.com/

Texting:

http://www.datawords.com/ International multi-language texting

iPad – Movies, Songs greyed out?

This did the trick for me:

1. Download and install iExplorer http://www.macroplant.com/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

Source: https://discussions.apple.com/thread/3979901?start=30&tstart=0

Solution by: https://discussions.apple.com/people/Galileo634

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

This is really all there is:

1. Download an Ubunto .iso from ubuntu.org
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: http://www.makeuseof.com/tag/how-to-create-an-ubuntu-installation-usb-on-the-mac/

10 steps to a Online Marketing Strategy

  1. Start with a web promotion plan and an effective web design and development strategy.
  2. Get ranked at the top in major search engines, and practice good Search Optimization Techniques.
  3. Learn to use Email Marketing Effectively.
  4. Dominate your marketing niche with affiliate, reseller, and associate programs.
  5. Request an analysis from an Internet marketing coach or Internet marketing consultant.
  6. Build a responsive opt-in email list.
  7. Publish articles or get listed in news stories.
  8. Write and publish online press releases.
  9. Facilitate and run contests and giveaways via your web site.
  10. Blog and interact with your visitors.

Source: http://marketing.about.com/od/internetmarketingstrategy/a/internettips.htm