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 #<a href="http://opencv.org/downloads.html">website</a>
#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 <a href="http://www.pztrick.com/blog/2013/05/11/ubuntu-guake-terminal-and-sublime-text-hackery/">this</a> 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

get xmonad suckless-tools #window manager

#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 (<a href="http://www.danscourses.com/Linux-Fundamentals/install-a-configure-squid-in-ubuntu.html">more info</a>)
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 <a href="http://www.jetbrains.com/idea/">IntelliJ IDEA</a> or <a href="http://www.sublimetext.com/2">Sublime</a> 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 (<a href="https://github.com/flexiondotorg/oab-java6/blob/master/README.md">docs</a>)
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 <a href="http://www.vmware.com/products/workstation/workstation-evaluation">Workstation</a>

#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
<a href="http://www.coppeliarobotics.com/downloads.html">v-rep</a>

*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.

On Categories and Concepts: Hofstadter Talk

This is a summary of a talk I attended at Stanford by Douglas Hofstadter (well known for his authorship of Gödel, Escher, Bach: An Eternal Golden Braid). He prefers lecturing without notes. I found it interesting/challenging to sort and summarize the main points of an improvised talk. Enjoy!

The label of a category can be anything from a conjunction to the essence of a situation

A paradigm for the situational label is Danny at the Grand Canyon.

Hofstadter’s family traveled to see the Grand Canyon. As Hofstadter turned his entranced gaze away from the great abyss, he rested his eyes on his son. His 1 year old son, Danny, sat facing away from the Grand Canyon and staring at ants. He was a child so young that he had no idea of distance. This situation can be generalized to the idea of focusing on what you’re interested in (and are capable of focusing on), harboring little interest in what others consider as gems.

Similarly, idioms are categories:
Left hand doesn’t know what the right hand is doing $\equiv$ One part of an organization is contradicting the other

Tail wagging a dog $\equiv$ small things have inordinately large control over a situation.

Conjunctions (logical connectives) are categories:
The conjunction “/” ($\equiv$ “slash”) is two things that aren’t quite exclusive combined together. Formally, let $A$ and $B$ be categories, a slash denotes ${A \cup B : A \cap B \neq \varnothing}$. For example: they’re a bimbo/self-marketing genius.

We may consider ourselves as each having a unique, private repertoire of categories (memories and thoughts)

We are a composition of public and private repertiores. The action of categorization is at the core of cognition. The difference between humans and other animals is the snowballing of categories; we continue to accrete categories to our repertiore through analogy.

These categories begin as a singleton: a set with one member. They evolve and blur into analogies as we add experiences to our private repitiores. This blurring may be coined as “pluralization”.

Reminders are analogies: unconscious thought pushed into consciousness by a situational queue.

The evolution of a category:
$$\text{Singleton}\rightarrow\text{Superimposed idea}\rightarrow\text{Pluralization}\rightarrow\text{Label}$$
He defines intelligence as the ability to put one’s finger on the essence of a situation rapidly. In other words, finding propelling analogies quickly.


Circumstances that evoke the choice of a category are extremely subtle

Without getting bogged down in examples, subtlety in is demonstrable in the difference between appropriate use-cases of “go to school” and “go to the school”.

  • “I have to stop by the school today to pick up my spectrometer.”
  • “Ender, you must go to school today.”

Many of cognitive science’s esoterics are bastardized versions of terms inherited from formal logic

In mathematics, predicate logic is an umbrella term for symbolic formal systems, informally, a predicate is a statement that is true or false depending on the values of its elements.

However, predicate calculus is “a general system of logic that accurately expresses a large variety of assertions and modes of reasoning”, capturing the essential logical structure of a complex idea independent of its elements.

The proposition Matvei loves Ubuntu can be represented by a predicate calculus in the form:

[Relationship between elements]([Subject element], [Object element])

However, a predicate calculus does not emit a yes or no. Likewise, category membership is not a boolean. Membership is fuzzy: the strength of membership is on a spectrum including central and peripheral membership of a given category.

Meaning is contextually dependent
The communication of ideas usually takes place through language: a stream of symbols flowing out of the mouth/fingers. Before symbolic exchange generates meaning, the situation must be explored and evaluated in the discourse space: a completely context dependent environment.
 
Sidenote: Hofstadter realized that meaning had a contextual dependence after he decided that his mathematically based notion that “all that matters in language is truth and falsehood” was incorrect.
 
 

Often, meaningful sounding questions are in fact meaningless due to ill-defined terms

When queried: How many languages do you know? He answers, “I’m $\pi$lingual”.

$\pi$lingual not in the sense that his knowledge of language is transcendental. Instead, $\pi$ is the result of summing of pieces of languages he knows into blurred fractions.

Before the question is meaningful, the questions What does it mean to know? let alone What does it mean to know a language? must be addressed.

Is it an efficient way to equate the meaning of 2 sentences to represent a network of word-relationships as a weighted graph? Or is this a seemingly logical but meaningless question due to fuzzy definitions?

My question, left unanswered/as an exercise for the reader.

Sources:
Cognitive Science: An Introduction to the Study of Mind Jay Friedenberg, Gordon Silverman

How Stockfish Works: An Evaluation of the Databases Behind the Top Open-Source Chess Engine

This is a paper I wrote my 3rd year of university as I was working on my Machine Learning-based Braille translator research. Enjoy!

Abstract

Playing chess has been on the forefront of AI research since Alan Turing and his students proposed chess playing machines. The game of chess is a domain of human thought where very limited sets of rules yield inexhaustible depths, challenges, frustration and beauty. The playing strategies of AI and human players have diverged proportional to the increase of available computing power, namely speed and storage space.
Human players recognize and aim to achieve particular patterns; typically, they perform a deep search weighted towards moves that lead to such desired patterns, transferring past knowledge and adapting it to their present situation.
AI chess is mostly played by parsing through a huge database, with broad search algorithms used to search for the next optimal move.
All chess engines work by looking at a heuristically determined subset of the legal moves stemming from a given position, and evaluating numbers to represent the new position’s relative value obtained by making those moves; then, recursively doing the same thing for the resulting positions. This is done using an evaluation function. An efficient evaluation function provides a better toolbox to guide the chess tree search, which improves the strength and speed of the AI player.
Stockfish is the top-ranked open-source chess engine, and I will be evaluating its elaborate use of databases; in particular, how Stockfish represents the state of the chessboard, evaluates the static board positions, uses its search algorithm, and uses past moves to optimize its next move.

Keywords: Chess, AI Chess, Search Techniques, Chess algorithms, Databases, Alpha-Beta Pruning, Stockfish, Stockfish 2.3.1

INTRODUCTION
 
Application Domain
 
It is important to distinguish between computer chess research and research using chess as a test bed. The latter expands the user community past chess enthusiasts to AI developers. In AI, the real-time evaluation and categorization of a dynamic environment is crucial to maintaining functionality while performing a task. This environment can be categorized using preset labels and rules or adapted to based purely on experience. Stockfish’s evaluation of chess positions, based not only on material properties (i.e. “I have more pieces than you”) but on the relationships and structures that exist between said material (i.e. “My piece is protected by two other pieces, and is threatening your unprotected piece.”), is useful in the domain of autonomous systems which must quickly evaluate the stability of groups of objects interacting within set rules. 

Project Motivation

The narrow view of this project’s motivation is to improve the strength of AI chess players. This engine’s effectiveness depends on proper tagging, passing, evaluating, and searching of chess positions.The main issues faced by AI chess players are:

  • Storing and evaluating data efficiently
  • Proceeding with the recursive search of moves

For most chess positions, computers cannot look ahead to all final possible positions. Instead, they must look ahead a few plies (a “ply” refers to one turn taken by one of the players. “Turn” is problematic since it means different things in different traditions. For example, in standard chess terminology, one move consists of a turn by each player; therefore a ply in chess is a half-move.) and then evaluate the final board position. The algorithm that evaluates final board positions is the evaluation function, which differs between different chess engines.

While the human method of analyzing alternatives seems to involve selecting a few promising lines of play and exploring them, computers are necessarily exhaustive rather than selective, so refinement techniques have been (and continue to be) developed.

Stockfish uses a complicated set of analysis functions depending on what material is on the board. By applying small changes and refinements (i.e. using categorical analysis) to alpha-beta pruning, there is a measurable difference in the time efficiency of pruning, without disregarding interesting nodes. Stockfish continues to expand as additions and tweaks are added by various developers.

Science Usage

The user requirements for Stockfish are mercifully little, for it is an open-source cross-platform engine. The only pre-requisites to using Stockfish are downloading the source code from their website. It may be run from the commandline or a UCI-Compatible GUI.

Goals

The ultimate goal of Stockfish is to unite the chess-program-developer community, and continue to a build stronger, faster chess engine.
This includes, among other things, a goal to improve the effectiveness of search evaluations. By creating an efficient board representation, this provides a better toolbox to guide the chess tree search, which improves the AI.

Alpha-beta pruning is just a complicated-sounding name for “Don’t check moves which cannot possibly have an effect on the outcome of your search.” The alpha-beta algorithm used in recursive search continues be improved. These enhancements come from the fact that if you restrict the window of scores that are interesting, you can achieve more cutoffs. The latest technique of move ordering is applied outside of the search, using iterative deepening boosted by a transposition table.

Results

Stockfish has clearly demonstrated that simple, brute-force approaches should not be quickly discarded. Additionally, iterative techniques, in particular, ideas developed for alpha-beta search and iterative deepening, are applicable to other search domains. Stockfish has clearly demonstrated the inadequacy of conventional AI techniques for realtime computation. Stockfish does not use AI languages or knowledge representation methods, for these conventions are too slow for a real-time, high performance application.

I have found that Stockfish represents the state of the chessboard using bitboards, it evaluates the static board positions using a categorical and statistical representation and uses an advanced alpha-beta search algorithm. In order to not analyze the same position several times, a transposition table is used. This is essentially memorization applied to the search function.

Design and Schema

The design of Stockfish is based on the interaction of various nodes (pictured in Schema).

A move search in Stockfish consists of 21 steps.

Step 1. Initialize node

Step 2. Check for aborted search and immediate draw. Enforce node limit here. (This only works with 1 search thread, as of Stockfish 2.3.1.)

Step 3. Mate distance pruning. Even if we mate at the next move our score would be at best mate_in($text{ss}rightarrowtext{ply}+1$, but if alpha is already bigger because  a shorter mate was found upward in the tree then there is no need to search further, we will never beat current alpha. Same logic but with reversed signs applies also in the opposite condition of being mated instead of giving mate, in this case return a fail-high score.

Step 4. Transposition table lookup. We don’t want the score of a partial search to overwrite a previous full search. We use a different position key in case of an excluded move.

Step 5. Evaluate the position statically and update parent’s gain statistics

Step 6. Razoring (is omitted in PV nodes)

Step 7. Static null move pruning (is omitted in PV nodes). We’re betting that the opponent doesn’t have a move that will reduce the score by more than futility_margin(depth) if we do a null move.

Step 8. Null move search with verification search

Step 9. ProbCut.  If we have a very good capture and a reduced search returns a value much above beta, we can (almost) safely prune the previous move.

Step 10. Internal iterative deepening.

Step 11. Loop through moves.  Loop through all pseudo-legal moves until no moves remain or a beta cutoff occurs

Step 12. Extend checks and also dangerous moves

Step 13. Futility pruning.

Step 14. Make the move

Step 15. Reduced depth search (LMR). If the move fails high will be re-searched at full depth.

Step 16. Full depth search, when LMR is skipped or fails high.

Step 17. Undo move

Step 18. Check for new best move

Step 19. Check for split

Step 20. Check for mate and stalemate

Step 21. Update tables. Update transposition table entry, killers and history

Stockfish begins by developing a legal-move tree, whence it must evaluate the resulting board positions. That is, the computer has to look at the pieces on the board and decide whether that arrangement of pieces is “good” or “bad.” The way it does this is by using an evaluation function. Since it is so important to evaluate the best move first, it might be worthwhile to execute a shallower search first and then use the resulting alpha/beta cutoff values as start values for a deeper search.

The chess evaluation function becomes more and more complicated by adding things like board position, control of the center, vulnerability of the king to check, vulnerability of the opponent’s queen, and tons of other parameters. No matter how complicated the function gets, however, it is condensed down to a single number that represents the “goodness” of that board position.

The main rules that govern the evaluation of position in Stockfish are as follows.

Pawn Structure

  1. Penalize doubled, backward and blocked pawns.
  2. Encourage pawn advancement where adequately defended.
  3. Encourage control of the center of the board.

Piece Placement

  1. Encourage knights to occupy the center of the board.
  2. Encourage queens and rooks to defend each other and attack.
  3. Encourage 7th rank attacks for rooks.

Passed Pawns

  1. These deserve a special treatment as they are so important.
  2. Check for safety from opposing king and enemy pieces.
  3. Add enormous incentives for passed pawns near promotion.

King Safety

  1. Encourage the king to stay to the corner in the middlegame.
  2. Try to retain and effective pawn shield.
  3. Try to stop enemy pieces from getting near to the king.

The same position will commonly occur from different move orders, thus most chess engines (including Stockfish) have a trasposition table (position cache). This is implemented using a hash table using the chess position as its key. Using a position cache instead of a hash table negates the need to evaluate large sub trees over and over again.

Alpha-beta pruning, without enhancements nor extensions, is represented in psuedo-Python below.

def alphaBetaMax (alpha, beta, depthleft):
   if (depthleft == 0): return evaluate()
   for (all moves):
      score = alphaBetaMin(alpha, beta, depthleft - 1 )
      if( score >= beta):
         return beta   #fail hard beta-cutoff
      if( score > alpha ):
         alpha = score #alpha acts like max in MiniMax
   return alpha
 
def alphaBetaMin(alpha, beta, depthleft )
   if ( depthleft == 0): return -evaluate()
   for (all moves):
      score = alphaBetaMax( alpha, beta, depthleft - 1 )
      if( score <= alpha ):
         return alpha #fail hard alpha-cutoff
      if( score < beta ):
         beta = score  #beta acts like min in MiniMax
   return beta
 
score = alphaBetaMax(-inf, +inf, depth)
print score

 

This schema shows the input with the current position, and ends with the next move, in order to avoid over-powering the simple nature of Stockfish by showing both method names and method parameters, I have created a representation of the overall use of databases in Stockfish.

The relationship of principle structures in the main database (governed by search.cpp)















Contents of Database

The contents of a typical chess engine database is past moves (moves that have been done in the past, very useful for the opening game), current moves (moves that are legal from a chess board’s current position) , and legal moves (rules governing the movement of each type of chess piece). Stockfish uses bitboard representation. Bitboards are a wonderful method of speeding up various operations on chessboards by representing the board by a set of 64 bit numbers.

A brief explanation of Bitboards is as follows: Supposing, for example, we generate a 64 bit number which represents the pawn structure on the chess board. We do this by starting at a8, and moving across then down in the sense a8,b8,c8,…,h8,a7,b7,c7,…,g1,h1. For each square, we put a ‘1’ if there is a pawn, or a ‘0’ otherwise. Then we have just one number on which we can perform all sorts of useful operations. Once we have a bitboard with all the possible destination squares set to ‘1’, we now have to cycle through them one by one. To do this, we require two routines. Firstly we require a routine which locates the position of the first bit in the bitboard which is set, and secondly we need a simple macro which then sets this bit to zero.

10 Questions 

Any chess player, human or AI, must answer the following question: What is the “best” move I can make next?. This answer is highly subjective, and depends entirely on what constitutes a “good” position. As humans, we easily recognize patterns, apply our past experience to current games, and use our intuition to judge the quality of play. However, a chess evaluator must find the strength of possible positions in a mechanical way, using a set of parameters (similar to the following questions) to describe and evaluate the strength of a given position.

Query 1) What is the position of all pieces on the board?

Query 2) What legal moves can each piece make from this position?

Query 3) What are relationships between pieces on the board? Are structures threatened or pieces undefended?

Query 4) Is there a strong pawn structure and effective pawn shield?

Query 5) Is the King mobile, well protected, and not in check?

Query 6) Is the center of the board occupied?

Query 7) Are any major pieces blocked?

Query 8) Are there passed pawns near promotion?

Query 9) Are bishops occupying major diagonals?

Query 10) What is the material difference between players?

After these 10 questions have been answered, the chess evaluator can score a position, and feed this score into the chess tree to optimize the $alpha-beta$ pruning that follows.

Algebraic Chess Notation
Symbol Meaning
a-h file from white’s left to right
1-8 rank from white to black
R, N, B/S, Q, K Rook, Knight, Bishop, Queen, King
x capture; the piece that was at this location is removed
+ a note that the king is threatened
# or ++ checkmate; a note that this is the reason for the end of the game
= promoted to; a pawn arriving at the opposite side of the board is promoted to another piece, often a queen.
0-0 castle on the kings side; move to positions (B – Kg8 Rf8 ; W – Kf1 Rg1) (if neither has moved before this point in the game)
0-0-0 castle on the queens side; (B – Kd8 Rc8 ; W – Kc1 Rd1) (if neither has moved before this point in the game)
e.p. en passant capture (non-SAN), a note that a pawn was taken by another pawn passing it. When a pawns first move is a two space move (from 7 to 5 for black or 2 to 4 for white) it can be captured by moving behind it to the 6th rank (white taking black) or 3rd rank (black taking white).
?, ??, !, !! editorial comments, weak, very weak, strong, very strong
Coordinates in Algebraic Chess Notation

Readers are encouraged to explore additional background information provided by the online book Building Skills in Python.

SOURCES

  1. H. Nasreddine and H. S. Poh, “Using an evolutionary algorithm for the tuning of a chess evaluation function based on a dynamic boundary strategy”, 2005. http://www.cs.nott.ac.uk/~gxk/papers/ieeecis2006.pdf.
  2. J. S. T. Anthony Marsland, Feng-hsiung Hsu and D. E. Wilkins, “The role of chess in artificial intelligence research”, http://ijcai.org/Past%20Proceedings/IJCAI-91-VOL1/PDF/084.pdf
  3. M. Strejczek, “Some aspects of chess programming”, http://www.top-5000.nl/ps/SomeAspectsOfChessProgramming.pdf.
  4. Wikipedia, “Ply(game theory)”, http://en.wikipedia.org/wiki/Ply_%28game_theory%29.
  5. T. Romstad, M. Costalba, J. Kiiski, D. Yang, S. Spitaleri, and J. Albett, “Stockfish about,” http://stockfishchess.org/about/.
  6. O. David-Tabibi, M. Koppel, and N. S. Netanyahu, “Optimizing selective search in chess”, http://www-kd.iai.uni-bonn.de/icml2010mlg/papers/DavidTabibiEtAl.pdf.
  7. T. Anantharaman, M. S. Campbell, and F. hsiung Hsu, “Singular extensions: Adding selectivity to brute-force searching”, Artificial Intelligence , pp. 99–109, 1990.
  8. I. Chernev, Logical Chess, Move By Move – Only Chess Book That Explains Every Move Of Every Game, 1957.
  9. D. Levy and M. Newborn, How Computers Play Chess,, Computer Science Press, New York, 1990.
  10. C. Frayn, “Computer chess programming theory”, 2005. http://www.frayn.net/beowulf/theory.html.

Random Thought: Thermoregulating Your Shower

As I was showering the water rapidly switched temperature and I found myself thinking of thermoregulation systems to amend this annoyance. 


I mentioned these thoughts to my friend, Chris Walker, and together we brainstormed possible solutions. 

My Suggestion
The hot knob is kept at max and a temperature sensor (connected to a microcontroller) is placed in the hot water pipe to detect significant temperature change. If temperature change is detected, the cold tap is moved accordingly via a stepper motor outside of the shower with a plastic rack & pinion. In my case, the cold tap is connected such that counterclockwise = more cold, clockwise = less cold. The microcontroller estimates the amount of cold water needed to compensate for the change in the hot water pipe until the main flow is within the accepted error bars, and adjusts the cold knob accordingly. For kicks, there is a green LED that alerts the user if the temperature is||is not within accepted bounds. 
Chris’s Suggestion
Shower usually have either one or two knobs. These arrangements locate temperature in Cartesian coordinates; where cold stream magnitude is your $x$ axis and hot stream magnitude is your $y$ axis. You have to reset it every time and estimate based on touch where the right hot/cold ratio is. This could be improved with polar coordinates: 
        1 knob for our $theta$ value, which determines the hot/cold ratio

1 knob for magnitude

After setting the $theta$ knob to a comfortable value once, turn the magnitude knob on or off when you get in or out. Less precise, but far simpler than my method.

This entire issue can be mitigated by turning the knobs to the same place each time to achieve the same temperature. This would not account for changes in available water pressure for your hot/cold pipes, slowly running out of hot water as the tank empties, that sort of thing.
Purely Mechanical Puzzle

It would be neat if you could get it to adjust for temperature and/or pressure with a fully mechanical system based on thermal expansion. Unfortunately, having a thermally expansive material jammed in the pipes would limit flow. The thermally expansive material would have to be fed through a high surface area/volume ratio, such as a much wider tube with a plug of expanding material in the middle. In any case, it would likely be highly impractical. It’s a neat idea to think about, though.
The most elegant solution seems to be a thermocouple, two solenoids, and a microcontroller.

Force Quit in Ubuntu

A surprising amount of Linux users are unfamiliar with how to force quit programs via the commandline. 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!