You Suck: The World We Knew

For as long as I can remember I have been trying to figure out how the world works. I started with what seemed obvious to me at the time; I looked into things like gravity, optics, how computers worked, and various other topics. As much information as was available at the time something very slowly came into focus: I suck at this task. Just like you.

The problem, however, is not you nor I per say. The problem is something Charles Sanders Peirce dubbed the phaneron. The gist here is that while we attempt to unravel the clues we glean from the information we receive it is all filtered through us. For example, although we now know the brain to do most of the information processing for our bodies, no human perceives vision without a photon first hitting the retina. There are so many steps throughout the process of vision, each with their own quirks, that there is no sure way to know the final result comes anywhere close to resembling the original phenomena. This even assumes the brain can be “trusted” to do what we expect it to do in the first place. For these reasons– and others– is why we conduct blind experiments, after all. This thought process is strange in that it implies that the brain and “we” are somehow separated but I am not aiming to write an academic dissertation here so deal with it, jerk.

As of late a lot of my focus has changed from what things and machines can I figure out, experiment with, build, and control to one of understanding some near analogs:

  • What are the technical implications of being a human trying to figuring things out?
  • How do human curiosity and expectations about things change the results of an experience while we are a thing in the sea of things of which we are trying to figure out?
  • Does it even make sense to think of ourselves as somehow special or not a part of “everything else”?
  • What concepts have we inferred due to all of this we should not have?

I am not necessarily going to answer these questions but am going to attempt to start on that path. It might first be important to break down the basic human components involved. In other words, what tools do we have that play a role in our understanding of gravity, optics, computers, and bacon cheeseburgers?

Vision
Cameras as we know them today capture frames. That is, a point-and-shoot camera captures a single image. Motion cameras capture multiple frames but still at least one entire image at any single instance in time. This gives us the most information possible encompassing about everything visual within range: A complete “picture”. Even the earliest of practical cameras had a resolution capable of reproducing a level of detail that allowed a human to easily make out details at a distance.

The eye, on the other hand, does not work this way. Most of the information gathered is discarded by the brain depending on a humans object of focus and thus never makes it into memory. To compound this only a small portion of the back of the eye (~2ยบ at a ~7 megapixels equivalent) is capable of any significant level of detail which does not even take into account the blind spots where the fovea or where the optical nerve meets the retina. In order to compensation the eye must rapidly dart around to build a “complete” image of the scene. Given the time this takes, no matter how quick, this makes it impossible to accurately track a sufficiently fast moving object as it once appeared.

Peripheral vision is even more limited. Unable to pick out even the largest of details its role is virtually solely limited to detecting motion from one moment to the next. Aside from notifying the brain the retina needs to be moved into place to view a new potential object of interest it can barley make out anything that would be deemed useful as a “frame.” If you place both of your thumbs, side-by-side, as far as you can in front of you then you will have a rough idea of everything not in your peripheral vision.

Oh, also right now you can not see your own nose despite it always being within your field of vision. Oh, wait… there it is.

The sheer amount of visual information that is right in front of you that you are aware of it astounding to me. Hey, it could be worse. You could have Anton-Babinski Syndrome.

Auditory
What is your favorite kind of music? What do the people around you sound like? How does a jack hammer differ from either of these two things?

It just does, right? I mean, music is pleasant and people can talk, neither of which I have ever heard from heavy construction machinery. The fact is our brains are very good at picking out patterns in noise even when there is no pattern to be found. Saying the same word over and over causes your sense of the word to slowly dissipate while listening to linear static occasionally causes things like animal sounds to magically appear.

Touch
When I was a child in childrens school I and the other children were taught touch is one of the basic senses (children). This is, of course, a drastic over simplification for the sake of the intended audience. Touch, as we traditionally think of it, is not a single sensation: there are at least hot, cold, pressure, and pain in addition to the traditional five senses.

Events starting or ending (say, touch) are difficult for a human to detect (we more commonly detect the continuation of the stimuli). For example, unknowingly touching a hot surface will instantly start destroying cells and our reaction to said stimuli (say, removing our hand from the hot surface) will often occur instantly. Since we were unaware of being burnt during this period it can not be said we “knew” anything about. Instead the reaction originates in and around the spinal column. Is your body preforming actions without your consent? You bet. In addition hot and cold are often mixed up by our senses. Imagine the sensation of burning while exposed to something extremely cold.

Here is a fun experiment:

  • Stick out your tongue.
  • Tap the side of your tongue exposed by your left cheek.
  • While still leaving your tongue exposed, flip it over.
  • Tap the opposite side of your tongue which is now on by your left cheek.

Did it feel like you touched the left side of your tongue each time? How could this be since the second time you were actually touching the right side? Our perception (or sense of proprioception, in this case) can very easily be fooled. In other words how could we ever surely know where we are in space?

Perception
One of the first things we learn in school is to count. One comes before two while ten comes after nine, ect. However most children struggle with this more than others. One proposal for this is that we are simply no good at perceiving things in this linear fashion. It is easy to imagine all the whole numbers that occur between one through ten but not so easy to imagine all the whole numbers that occur between one to 1,000,000. There is no difference in the way you arrive from the first variable to the second to the third and so on yet our brains struggle to comprehend even the most common number of things (people in your city, for example). They remain abstract concepts for us even if we know the exact answer.

This can pretty easily be illiterate with the following example: Imagine you are considering making a purchase of $10. Would a $5 off coupon help you make up your mind? Now imagine, instead, that purchase price was $1,000. What are the chances of a $5 off coupon effecting your decision to pull the trigger now? If you are like me your gut says $5 was more valuable in the first scenario. However saving $5 is saving $5 no matter how much the final total comes to. The evidence suggests we were born to work in gradations leaving us unprepared to make logical decisions in the real world in which we live.

Logic
Consider the following problem:
Person A is looking at Person B. Person B is looking at Person C. Person A is married while Person C is not. Is a married person looking at an unmarried person?

The possible answers are “yes,” “no,” and “not enough information.” Think about it for a moment… did you come up with “not enough information?” So did I. So did most people. However the answer is “yes.” You see, if Person B is married they are looking at Person C (an unmarried person). However if Person B is unmarried Person A is looking at them.

The postulates we make, live our lives by, and blindingly accept as fact might never have been so.

Time and Space
Probably my personal favorite in our list, this one screws with peoples heads. Since this topic is so huge I am only going to propose one of Einsteins simple thought experiments and let you investigate the implications.

Imagine two people, one riding on a train (Person A) and the other standing on the tracks (Person B) where the train is passing by. Person A bounces a ball hard enough so that, after bouncing off the floor, it travels straight up and hits the ceiling. Therefore Person A witnessed the ball bounce X distance at Y speed. However Person B, since the train is moving, witnesses the same event (the ball bouncing from floor to ceiling) as traveling the same speed but within a larger distance within the same time period. How could the same ball travel the same speed but cover a larger distance in the same amount of time? Neither observation is incorrect but they seem contradictory. A variation of the same thought experiment can also demonstrate space– and thus matter– itself is not fixed but changes based on the observer.

Of the many points illustrated in this example one of the take-aways is that it is not possible to know if you are seeing what someone else is seeing. All the information filtered through your phaneron may, in fact, be feeding you “false” information which you have no reason to believe is not what occurred. Causality even comes into question.

Lack of Senses
What about everything else? Are there things out there invisible to all of our senses? Some birds have been show to navigate by magnetism. Insects can see “colors” outside the spectrum of light we can perceive. Between naturally occurring and man-made radio signals we are bombarded 24/7 by exploding stars and mobile phone calls. None of these unperceived occurrences caused us any sensory input giving us an even less complete picture of our surroundings than we thought we had before we even realized our own shortcomings. Does the light in the freezer even go off when you close the door? Do other people stop existing if you close your eyes?

Injury
Your brain has a lot of information coming at it all day long. Of course this sole aggregator of the sense needs to take some short cuts in order to deal with it all.

What happens when this central hub becomes damaged? Would you even know it? Do all people with schizophrenic hallucinations realize the things they feel, see, or hear are not there? How could you tell that perceived voices coming from your left are coming from your left at all? Are the real things in your environment real things? Are you even sure you are hearing everything there is to hear?

Check out the cases of Phineas Gage, Henry Molaison, and the book The Man Who Mistook His Wife for a Hat by Oliver Sacks.

Philosophy
This deserves much more written about it than I will here but a few things to look up:

Closing
Given perfect vision and a perfect sense of time and a perfect sense of space, would it theoretically be possible to perceive the world as it really is? Maybe. If you could would it appear anything like you believe it to appear today? If I have covered anything here it is that we may never know.

So what does this all mean? Does it render the world or our existence meaningless? Yes. No. Irrelevant. Not applicable. If all this information is new to you and you now feel somehow differently about some subject remember that the only thing that has changed is “you”. Personally I suggest trying to stop thinking in yes/no terms; accept you are one with everything in the same sense that there is no difference between yourself, words, the wind, ideas, right, wrong, happiness, or emptiness.

By the way, if anyone wants to base a magic show on this article I want free tickets.

Steam Running in Windows Compatibility Mode

After a recent Steam update I started getting a warning about Windows Compatibility Mode. A quick check of both the shortcut and the executable itself revealed that no such setting was set. At first I was ignoring it as a fluke of Windows but it started screwing with my games… I need muh vida gumes!

The fix was simple, although annoying. Check the following regedit paths for the steam.exe executable. If you find any delete them and reboot.

  • HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
  • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
  • HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Persisted

This fixed the issue for me. Good luck to you.

Ubuntu 14.04 LXC Setup with Unprivileged Containers

I have been spending a lot of time searching for alternatives to virtual machines. I do love my VMs but I hate the idea of dedicating resources (such as RAM) that never get used. There is memory ballooning but it is a trade off for the usage of other resources. Also I am crazy and obsessive about efficiency. VMs still have their place but we now have a new, awesome tool available to us: LXC.

Install

The LXC team offers us a PPA making this setup super easy. This will also handle future updates for us.

Install the software…
sudo apt-add-repository -y ppa:ubuntu-lxc/stable
sudo apt-get update
sudo apt-get install lxc

Network

Optional
You could skip this step but then you would only be able to access your containers on the same host on which they are run. There is also port forwarding (say, via iptables) but that is overly complicated for anything other than simple TCP/UDP stuff (and boring). We are going to do a bridge so that all containers can access the network and all remote hosts can access the containers as if they were physical machines on the network.

This should have been installed with LXC but just to be safe…
sudo apt-get install bridge-utils

Fire up your favorite text editor and open /etc/network/interfaces. In it add
auto lxcbr0
iface lxcbr0 inet static
 address [primary IP address]
 netmask [primary netmask]
 gateway [primary gateway]
 dns-nameservers [primary DNS server(s)]
 bridge_ports [primary network interface]

replacing everything above within and including the brackets.

Next we need to replace all lines for the primary network interface with
iface eth0 inet manual

You may have multiple network segments. Configuring this is left as an exercise for the user.

Unprivileged Containers

We could just start creating containers now. However a potential problem may arise as they will all be run as root. Theoretically this is fine because you should never be able to break out of a container but bugs happen. So we are not making ourselves more vulnerable than we need to be we will be setting up unprivileged containers to be run as our unprivileged user.

Allow our user account to use the bridge…
echo "$USER veth lxcbr0 1024" | sudo tee -a /etc/lxc/lxc-usernet

Create Upstart script…
In /etc/init/lxc-unprivileged.conf add…
description "LXC Unprivileged Containers"
author "Mike Bernson <mike@mlb.org>"

start on started lxc

script
 USERS="[user]"

 for u in $USERS; do
  cgm create all lxc$u
  cgm chown all lxc$u $(id -u $u) $(id -g $u)
  lxc-autostart -L -P /home/$u/.local/share/lxc | while read line;
  do
   set -- $line
   /usr/local/bin/startunprivlxc lxc$u $u $1
   sleep $2
  done
 done
end script

Make sure to replace [user] with your user account.

Create the container start script…
In /usr/local/bin/startunprivlxc add…
#!/bin/sh

cgm movepid all $1 $$
sudo -iH -u $2 -- lxc-start -n $3 -d

… and make it executable…
sudo chmod +x /usr/local/bin/startunprivlxc

Create our mappings and settings for our containers to use…
mkdir -p ~/.config/lxc/
echo "lxc.id_map = u 0 100000 65536" > ~/.config/lxc/default.conf
echo "lxc.id_map = g 0 100000 65536" >> ~/.config/lxc/default.conf
echo "lxc.network.type = veth" >> ~/.config/lxc/default.conf
echo "lxc.network.link = lxcbr0" >> ~/.config/lxc/default.conf

Create Contaiers

Here is where the magic happens.

lxc-create --name [name] --template download

Again with the text editor open ~/.local/share/lxc/[name]/config. In it add
lxc.start.auto = 1

Make sure to replace [name] with your container name in both commands.

These two steps will allow you to create new, unprivileged containers which autostart on boot running the distribution, release, and architecture of your choice.

Attach to Contaiers

In order to get into the console you only need a single command…
lxc-attach --name [name]

If you like you can use this to install an SSH server (do not forget to setup a new user so you are not logging in as root). You could also just log into the host and lxc-attach each time. Up to you.

More

There are many more things you can do. For example, create separate networks (say, one for public communications and another for container-to-host-to-container communications) or limit resources so one rouge container does not ruin it for the others and the host itself. A dedup‘ing filesystem (such as ZFS) would also probably get great ratios.

Research, experiment, and play with this very cool bit of engineering.

Sources

https://www.launchpad.net/~ubuntu-lxc/
https://help.ubuntu.com/lts/serverguide/network-configuration.html
https://help.ubuntu.com/lts/serverguide/lxc.html

Thanks

Mike Bernson

https://lists.linuxcontainers.org/pipermail/lxc-users/2015-January/008221.html
https://lists.linuxcontainers.org/pipermail/lxc-users/2015-January/008222.html

Compile and Install PostgreSQL 9.2.x from Source on Ubuntu 13.04 Server

Working on a project for which I am using MySQL. As much as I love the thing it has been scaring me a little since Oracle bought them. They have pledged to keep the project open-source friendly a while back but I still worry. PostgreSQL seems like it might be a good fit for me so here are the steps I took to get it up and running from source on Ubuntu 13.04 Server.

  • Make sure our required tools are installed:


    sudo apt-get update
    sudo apt-get install zlib1g-dev libreadline6-dev gcc make

  • Download the latest source and extract:


    wget ftp://ftp.postgresql.org/pub/source/v9.2.x/postgresql-9.2.x.tar.bz2
    tar xjfv postgresql-9.2.x.tar.bz2

    Note
    I am using v9.2.4 for this example as it was the latest at the time of this writing. Simply replace x with your version number.

  • Compile and install:


    cd postgresql-9.2.x/
    ./configure
    make -j y world
    sudo make install-world

    Note
    Replace y with the number of processor cores you would like to use. This step generally does not take long so if you wanted to omit -j and its argument all together that would also work.

  • Copy start up script:


    sudo cp contrib/start-scripts/linux /etc/init.d/postgresql

  • Remove working directory:


    cd ../
    rm -rf postgresql-9.2.x/
    rm postgresql-9.2.x.tar.bz2

  • Add user:


    sudo useradd postgres

  • Create data directories:


    sudo mkdir /var/lib/postgresql/
    sudo chown postgres:postgres /var/lib/postgresql/

    Create data:


    sudo su - postgres -c "/usr/local/pgsql/bin/initdb -D /var/lib/postgresql/"

  • Create configuration directory:


    sudo mkdir /etc/postgresql/
    sudo chown postgres:postgres /etc/postgresql/

    Move configuration:


    sudo mv /var/lib/postgresql/postgresql.conf /var/lib/postgresql/pg_hba.conf /var/lib/postgresql/pg_ident.conf /etc/postgresql/

    Open postgresql.conf:


    sudo nano /etc/postgresql/postgresql.conf

    Change postgresql.conf:


    data_directory = '/var/lib/postgresql/'
    external_pid_file = '/var/run/postgresql.pid'

    Note
    These are the bare minimum changes. You will probably want to scan the file and change it to better suit your needs.

  • Open start up script:


    sudo nano /etc/init.d/postgresql

    Change start up script:


    PGDATA="/etc/postgresql/"
    PGLOG="/var/log/postgresql.log"

    Under ## EDIT FROM HERE add:


    PGGROUP=postgres
    PGPID="/var/run/postgresql.pid"

    Above su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1, under start) add:


    touch $PGPID
    chown $PGUSER:$PGGROUP $PGPID

    Under su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast", under stop) add:


    rm $PGPID

  • Make start up script executable:


    sudo chmod +x /etc/init.d/postgresql
    sudo update-rc.d postgresql defaults

  • Start service:


    sudo service postgresql start

  • [Optional] Make commands available to all users:


    sudo ln -s /usr/local/pgsql/bin/* /usr/local/bin/

    [Optional] Make C includes and libraries available to all users:


    sudo ln -s /usr/local/pgsql/include/* /usr/local/include/
    sudo ln -s /usr/local/pgsql/lib/* /usr/local/lib/
    sudo ldconfig

    Note
    These just make life slightly easier. If you prefer you can always just call everything by their absolute paths or put them in your $PATH.


Sources
http://www.postgresql.org/docs/current/static/installation.html
http://www.postgresql.org/docs/9.2/static/server-start.html

Compile and Install Redis 2.6.x from Source on Ubuntu 13.04 Server

Working on a project for which I am using MySQL. As much as I love my relational databases they may not always be the best tool for the job. As such, for the first time, I am evaluating other solutions. Redis seems like it might be a good fit for me so here are the steps I took to get it up and running from source on Ubuntu 13.04 Server.

  • Make sure our required tools are installed:


    sudo apt-get update
    sudo apt-get install make gcc

  • Download the latest source and extract:


    wget http://redis.googlecode.com/files/redis-2.6.x.tar.gz
    tar xzfv redis-2.6.x.tar.gz

    Note
    I am using v2.6.14 for this example as it was the latest at the time of this writing. Simply replace x with your version number.

  • Compile and install:


    cd redis-2.6.x/
    make -j y
    sudo make install

    Note
    Replace y with the number of processor cores you would like to use. This step generally does not take long so if you wanted to omit -j and its argument all together that would also work.

  • Copy and open Redis configuration:


    sudo mkdir /etc/redis/
    sudo cp redis.conf /etc/redis/
    sudo nano /etc/redis/redis.conf

    Change the following options:


    daemonize yes
    dir /var/lib/redis/
    syslog-enabled yes
    syslog-ident redis
    syslog-facility local0

    Note
    These are the bare minimum changes. You will probably want to scan the file and change it to better suit your needs.

  • Remove working directory:


    cd ../
    rm -rf redis-2.6.x/
    rm redis-2.6.x.tar.gz

  • Add user:


    sudo useradd redis

  • Create data directories:


    sudo mkdir /var/lib/redis/
    sudo chown redis:redis /var/lib/redis/
    sudo mkdir /var/log/redis/
    sudo chown redis:redis /var/log/redis/

  • Setup start up script:


    sudo nano /etc/init.d/redis-server

    Within this file add the following and save/close:


    #! /bin/sh

    ### BEGIN INIT INFO
    # Provides: redis-server
    # Required-Start: $syslog $remote_fs
    # Required-Stop: $syslog $remote_fs
    # Should-Start: $local_fs
    # Should-Stop: $local_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: redis-server - Persistent key-value db
    # Description: redis-server - Persistent key-value db
    ### END INIT INFO

    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DAEMON=/usr/local/bin/redis-server
    DAEMON_ARGS=/etc/redis/redis.conf
    NAME=redis-server
    DESC=redis-server
    PIDFILE=/var/run/redis.pid

    test -x $DAEMON || exit 0

    set -e

    case "$1" in
    start)
    echo -n "Starting $DESC: "

    touch $PIDFILE
    chown redis:redis $PIDFILE

    if start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON -- $DAEMON_ARGS
    then
    echo "$NAME."
    else
    echo "failed"
    fi

    ;;

    stop)
    echo -n "Stopping $DESC: "

    if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
    then
    echo "$NAME."
    else
    echo "failed"
    fi

    rm -f $PIDFILE

    ;;

    restart|force-reload)
    ${0} stop
    ${0} start

    ;;

    status)
    echo -n "$DESC is "

    if start-stop-daemon --stop --quiet --signal 0 --name ${NAME} --pidfile ${PIDFILE}
    then
    echo "running"
    else
    echo "not running"

    exit 1
    fi

    ;;

    *)
    echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2

    exit 1

    ;;
    esac

    exit 0

    Make script executable:


    sudo chmod +x /etc/init.d/redis-server
    sudo update-rc.d redis-server defaults

  • Start the server:


    sudo service redis-server start


Notes

  • I have not experimented with this on a 32-bit machine but I doubt it would be very useful for anything other than seeing what is what. If you are going to use this in anything remotely resembling a production environment I would use a 64-bit machine without question.
  • I disabled snapshotting for my tests as I will not need it. If you end up using it– such as in the default configuration– you might want to add vm.overcommit_memory = 1 to /etc/sysctl.conf.