Linux Laptop Environment Setup

I’m regularly asked about the setup of my laptop: a System76 Gazelle Professional named Felix running Ubuntu 14.04. Writing a return to that query produced the following:

Chromium Addons:

Pocket #Formerly Read It Later
Lazarus
GmailTeX #Gmail + LaTeX = GmailTeX
AdBlock [for YouTube] #Saves time
Session Buddy
Diigo
HTTPS Everywhere
Disconnect
Incognito-Filter #Great for keeping facebook.com, accounts.google.com, etc. from hijacking web history
Hacker Vision #Save your eyes!
The Great Suspender #Suspends tabs not in use
What font? #satisfies curiosity
Wolfram Alpha
GHangouts
Chrome Downloads
Have I Downloaded This Before?
BetterTube #Optimize your YouTube experience

Get Flashplugin working on Chromium:

get adobe-flashplugin
#if that doesn't work, try:
sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update && sudo apt-get install flashplugin-installer

Some of my favorite term aliases*:

alias up='sudo apt-get update && sudo apt-get upgrade'
alias meta='sudo vi ~/.bashrc'
alias rmeta='. ~/.bashrc'
alias sag='sudo apt-get'
alias cx='chmod +x'
alias purge='rm `find *~`'
alias ip='ifconfig | grep "inet addr:"| grep -v "127.0.0.1" | cut -d: -f2 | awk "{ print $1}"'
alias get='sudo apt-get install'
alias matlab='matlab -glnx86'
alias p='python'
alias pipi='sudo pip install'
alias sim='cd ~/V-REP_PRO_EDU_V3_0_4_64_Linux/ && ./vrep.sh'

Python-based Research:

get python-pip #pip for managing packages
get build-essential liblapack-dev gfortran gcc g++ 
#Either the ATLAS or OpenBLAS implementation of BLAS. OpenBLAS is speedier but finnicky wrt multiprocessing.
get libatlas-dev libatlas3-base 
#or
get libopenblas-dev
sudo easy_install -U distribute
pipi dev numpy scipy setuptools matplotlib
pipi nose #nicer testing
#Machine Learning
pipi -U scikit-learn
#Computer Vision
get gcc g++ cmake
#download latest opencv from #website
#untar it with
tar -xvf opencv-* #or
unzip opencv-*
#inside untarred folder make new folder call "r" (arbitrary name)
#run the following command in it
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_NEW_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON ..
make
make install

A few choice packages/programs:

get guake #drop down term window - crazy useful (Sublime users: check this out)
get vim
get screen
get tex4ht #convert LaTeX to html
get chromium-browser #Preferred browser
get gparted #for managing partitions
get wine #Run (some) Windows on Linux
get haskell-platform
get vlc #My favorite multimedia plugin
get ipython #Bro, do you even Python?
get texmaker #LaTeX editor of choice (gedit plugin is also nice)
get openjdk-6-jre openjdk-7-jre #Open source Java platform
get geary #Alternative to thunderbird
get gwenview #crop pictures
get p7zip #extract *.7z files
get unrar #extract rar
get bleachbit #free your disk space
#ffmpeg
get libav-tools
sudo add-apt-repository ppa:samrog131/ppa
sudo apt-get update
get ffmpeg
#dropbox
cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -
~/.dropbox-dist/dropboxd
#broke grub?
sudo add-apt-repository ppa:yannubuntu/boot-repair
up
get -y boot-repair
boot-repair #run boot-repair after installation
#Be safe, use a proxy or VPN (more info)
get squid squid-common
#Note: If you are running 13.04, sudo service squid3 (start|stop|restart)
#evernote on linux
sudo add-apt-repository ppa:nvbn-rm/ppa
sudo apt-get update && sudo apt-get install everpad
#numlock activates at startup
sudo apt-get -y install numlockx
sudo sed -i 's|^exit 0.*$|# Numlock enablen[ -x /usr/bin/numlockx ] && numlockx onnnexit 0|' /etc/rc.local
"""
For quick scripting, I use or IntelliJ IDEA or Sublime with vim command mode enabled. 
To enable control mode in Sublime Text 2: Find Preferences.sublime-settings 
Change the line "ignored_packages": ["Vintage"] to "ignored_packages": []. 
Restart Sublime: boom! Vim controls.
"""
#xscreensaver
sudo apt-get remove gnome-screensaver
sudo apt-get install xscreensaver xscreensaver-data-extra xscreensaver-gl-extra
#Oracle(Sun) Java (docs)
cd ~/
wget https://github.com/flexiondotorg/oab-java6/raw/0.3.0/oab-java.sh -O oab-java.sh
chmod +x oab-java.sh
sudo ./oab-java.sh
get sun-java6-jre
#VMWare Workstation
#compiz
get compiz compizconfig-settings-manager compiz-fusion-plugins-extra compiz-fusion-plugins-main compiz-plugins
#matlab from cd
cd /media/MATLAB{version}
gksu ./install
#blender
sudo add-apt-repository ppa:irie/blender
sudo apt-get update
get blender
get myunity #Awesome control panel for unity
#Deprecated: get unity-tweak-tool 
#My free robotics simulator of choice, the educational version is free for all and available for OSX, Windows, 32 and 64bit Linux
v-rep

*To edit your own cd && vim ~/.bashrc
After editing, refresh your bashrc with . ~/.bashrc. Now your aliases can be used! Huzzah!

Using a US Keyboard Layout to type in German? Lesen diesen Beitrag für deutsche Tastaturkürzel.

Force Quit in Ubuntu

A surprising amount of Linux users are unfamiliar with how to force quit programs via the command-line. It is often that your only option to escape a process gone awry is using the term window.

I was coding with some friends yesterday and to my surprise, they didn’t know how to quit an unresponsive process. I fear that this ignorance is widespread. The procedure is fairly simple. Use the following command to list ongoing processes:

ps x

After you’ve located the UID of the problem process (usually a 4 or 5-digit natural number), kill it.

Let’s say our UID is 27182.

kill -9 27182

Done!

Adding Weather Indicator

Get Weather on the Unity top panel in Ubuntu! Worry not, this tutorial doesn’t assume any term aliases.

sudo add-apt-repository ppa:weather-indicator-team/ppa
sudo apt-get update
sudo apt-get install indicator-weather

If you’d like the indicator to launch upon startup, hit the super key and search for Startup Applications. Click on the icon, click Add, pick an arbitrary name, and enter indicator-weather as the command.

Sidenote:
I personally prefer to use Celsius. If you were raised with the Imperial system, then I suggest using the following poem to transition.

30’s hot,
20’s nice,
10’s cold,
0’s ice.

Happy hacking!

Writing in German: Keyboard Shortcuts

Want to type in another language but you love your US keyboard layout?

Fear not. In Linux, this power is acquired as follows:

System Preferences -> Keyboard Layout
Click Options (bottom right-hand corner)
Expand Compose key position
Check Right Ctrl is Compose

Now that we have a functional compose key, we can utilize it to combine characters (sequentially). You now have the power to combine multitudes of characters; this is a German tutorial, so I’ll cover ß, ä, ü, and ö.

ß = RCtrl -> s -> s

This procedure imposes an umlaut on a, o and u:

ä = RCtrl -> " -> a

Tschüß und Happy Hacking!

Installing CoffeeScript on Ubuntu 13.04

Unfortunately, the current CoffeeScript docs do not support installation on the latest Ubuntu distro. To get around this, we must manually install the dependencies. Don’t worry, I’ve done most of the work for you.

Create a plain text file, vi installcoffee.sh and insert the following:

sudo apt-get update
sudo apt-get install git-core curl build-essential openssl libssl-dev
git clone https://github.com/joyent/node.git && cd node
./configure
make 
sudo make install
cd
curl http://npmjs.org/install.sh | sudo sh
sudo npm install -g coffee-script

Save Esc + : + w and run the script . installcoffee.sh

Bash Scripts I Use With Github

I’ve recently decided that I should put some of my projects on GitHub.

I use two bash scripts to ease my communication with my repo.

. gitpush.sh

cd [path to local repo]git add .
git status
git commit
git push origin HEAD:master
git diff HEAD~1 HEAD > ~/Desktop/diff.txt

. gitrm.sh filename

file=$1
git rm $file
git commit -m "remove $file"

Setting Up pygeoip Environment on Ubuntu

GeoIP uses a large database to find information about a given IP address or website. I went through a couple different package installations before it integrated with my programs successfully. The fairly simple process I settled upon to set up the functional package, pygeoip (python API for GeoIP), is as follows:

sudo easy_install pygeoip
cd /usr

To find the path of GeoIP.dat, embrace the power of `  (not ‘, `  on US keyboards shares a key with ~).

find `pwd` -name 'GeoIP.dat'

After downloading GeoLiteCity.dat, a simple way rename the file to GeoIPCity.dat whilst moving said file to the same path as GeoIP.dat (for convenience)…

sudo mv Downloads/GeoLiteCity.dat /usr/share/GeoIP/GeoIPCity.dat

In order to check the success of your environment’s set-up, run this as a py script or in a term window

import pygeoip
#gi = pygeoip.GeoIP('/usr/share/GeoIP/GeoIP.dat', pygeoip.MEMORY_CACHE)
gi = pygeoip.GeoIP('/usr/share/GeoIP/GeoIPCity.dat)
print gi.record_by_addr('64.233.161.99')