<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Apreche.net</title>
	<atom:link href="http://www.apreche.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.apreche.net</link>
	<description>One geeks thoughts on the geekeries of the world.</description>
	<lastBuildDate>Fri, 28 Dec 2012 01:22:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Complete Single Server Django Stack Tutorial</title>
		<link>http://www.apreche.net/complete-single-server-django-stack-tutorial/</link>
		<comments>http://www.apreche.net/complete-single-server-django-stack-tutorial/#comments</comments>
		<pubDate>Thu, 27 Dec 2012 20:10:06 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1339</guid>
		<description><![CDATA[Introduction I notice a lot of people these days using Heroku to host applications they&#8217;ve written with Django or Rails. This may save them some time and effort, but they are spending way more money on this specialized hosting than &#8230; <a href="http://www.apreche.net/complete-single-server-django-stack-tutorial/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<h1>Introduction</h1>
<p>I notice a lot of people these days using <a href="http://www.heroku.com/">Heroku</a> to host applications they&#8217;ve written with <a href="https://www.djangoproject.com/">Django</a> or <a href="http://rubyonrails.org/">Rails</a>. This may save them some time and effort, but they are spending way more money on this specialized hosting than they would pay for a generic Linux host. They are also giving up control of a large portion of their application. I consider the entire stack to be part of my application, and complete control over all the pieces is mandatory.</p>
<p>Because I encourage people to administer their own servers, I have written this tutorial to remove just one more of their excuses not to do so. This tutorial covers everything you need to do to configure a blank <a href="http://releases.ubuntu.com/precise/">Ubuntu Linux 12.04 LTS 64-bit server</a> to run a Django application properly. I will not be covering anything about writing the application itself. I will also only provide minimal discussion of some topics, like database configuration. If you can finish this tutorial, you can Google the necessary documentation for other things. The only thing I completely skip is configuration of search using <a title="Haystack" href="http://haystacksearch.org/">Haystack</a> and <a href="http://lucene.apache.org/solr/">Solr</a> since it is not needed by most applications.</p>
<p>If you want to use a different Linux distribution, most of this tutorial will still be correct. You will have to translate all of the apt-get statements and package names to your distribution of choice. Configuration file paths and layouts may also differ. I chose Ubuntu 12.04 because it is very popular, available on almost every host, and its long term support will keep this tutorial relevant for a longer period of time.</p>
<h1><span id="more-1339"></span>Formatting</h1>
<p>In this tutorial all commands and lines of code that you should actually enter are displayed in preformatted text. Within the preformatted text there will be lines that begin with an octothorpe (#). Those lines contain my personal comments on the surrounding lines, and should not be typed. Lines beginning with the dollar symbol ($) are commands that should be typed on the shell. In cases where there are variables that you should replace with appropriate values, I will surround the variable with &lt;&gt; symbols and name it with all capital letters.</p>
<pre># This text is describing the command below it. Don't type it.
$ this is a shell command, type it

# Type the following command, but replace the &lt;USER&gt; with your username
$ sudo adduser &lt;USER&gt;</pre>
<p>In cases where edits must be made to a file I will begin that section with a shell command to open the appropriate file in vim, which is my text editor of choice. You may use whichever text editor you wish. I will also describe the edits to be made in the comment text.</p>
<pre>$ vim test.txt

# add this line to the end of the file
TEST = True</pre>
<h1>Tutorial</h1>
<h2>Beginning Steps</h2>
<p>Begin by installing Ubuntu on a machine you own, or getting a new machine from a hosting provider. I recommend <a href="http://www.linode.com/">Linode</a> or <a href="http://aws.amazon.com/ec2/">Amazon EC2</a>. If you choose EC2 the <a href="http://cloud-images.ubuntu.com/locator/ec2/">Ubuntu AMI finder</a> should be your starting point.</p>
<p>Once the machine is installed, you will need to login, mostly likely using <a href="http://www.openssh.com/">SSH</a>. I can not more strongly recommend you use <a href="http://www.unixwiz.net/techtips/ssh-agent-forwarding.html">SSH Agent Forwarding</a>. I will not cover how to set it up in this tutorial, as it varies based on your client machine. If you haven&#8217;t done this already, do it now.</p>
<p>Once you are logged into the machine, you will probably notice it is telling you that a lot of packages need updating. You should update packages whenever they need updating, especially if there are security patches. Just be aware this may disrupt your site for a few minutes. If your site were important enough to where a minute of downtime was a problem, you would not need this tutorial. Here is how you update all packages on an Ubuntu or Debian system.</p>
<pre># update the local package index
$ sudo apt-get update

# actually upgrade all packages that can be upgraded
$ sudo apt-get dist-upgrade

# remove any packages that are no longer needed
$ sudo apt-get autoremove

# reboot the machine, which is only necessary for some updates
$ sudo reboot</pre>
<p>You may notice frequent use of sudo. Sudo is a program that allows us to execute other commands with root privileges. If you are bothered having to type your password when using sudo, then you can <a href="http://askubuntu.com/questions/135821/can-i-run-sudo-without-entering-a-password">edit your sudoers</a> file to make it easier in the future.</p>
<h2>distribute and pip</h2>
<p>Many of the Python packages we need are available through Ubuntu and apt-get. However, we do not want to use them. The packages provided by Ubuntu are very likely to be old and out of date. Also, it is only possible to install them globally, whereas we would like to install them in an isolated fashion. If we ran two sites on this server that used different versions of Django, this method would not work.</p>
<p>Many of the Python packages are wrappers around C libraries that will need to be available for linking. Those C libraries must be installed using apt-get before we install the associated Python packages. There are two such packages that are needed for just about everything, and should be installed now. They are build-essential and python-dev. Build-essential is the Ubuntu package which provides all the standard C compilation tools. Python-dev provides the necessary files for compiling Python/C modules.</p>
<pre>$ sudo apt-get install build-essential python-dev</pre>
<p>Now, there are various tools to install Python packages, and there is much drama and debate in the community about them. I will ignore all that, and say to use <a href="http://packages.python.org/distribute/">Distribute</a> and <a href="http://www.pip-installer.org/en/latest/">pip</a>. I have used them for years now, and have had no issues at all.</p>
<pre># download distribute
$ curl -O http://python-distribute.org/distribute_setup.py

# install distribute
$ sudo python distribute_setup.py

# remove installation files
$ rm distribute*

# use distribute to install pip
$ sudo easy_install pip</pre>
<h2>Virtualenv(wrapper)</h2>
<p>Now that we have used distribute to install pip, we will use pip to install every other Python package. This solves the problem of getting packages, but it does not solve the problem of isolating them. For that we must use <a href="http://www.virtualenv.org/en/latest/">virtualenv</a>. Because virtualenv itself is a little clumsy, we will also use <a href="http://www.doughellmann.com/projects/virtualenvwrapper/">virtualenvwrapper</a> to make things a little easier on ourselves.</p>
<pre># install virtualenv and virtualenvwrapper
$ sudo pip install virtualenv virtualenvwrapper

# edit the .bashrc file
$ vim .bashrc

# to enable virtualenvwrapper add this line to the end of the file
source /usr/local/bin/virtualenvwrapper.sh
#save and quit your editor

# exit and log back in to restart your shell
$ exit</pre>
<p>You will notice after exiting and logging back into the shell that virtualenvwrapper will do a bunch of magic. That is a one-time setup that you will never see again. If you don&#8217;t see a bunch of stuff happen, then there is a problem you should fix.</p>
<p>Now, how do you use virtualenv? You create as many virtualenvs as you like, each with a unique name. Only one of these virtualenvs will be active at a given time. Any time you use pip the packages will only be installed into the active virtualenv. In order for a Python program to make use of those Python packages, it must be executed with that virtualenv activated. Let&#8217;s create a virtualenv for our project and activate it. You should just keep it active for the rest of this tutorial for ease. You can tell when a virtualenv is active because it will appear in your shell prompt.</p>
<pre># create a virtualenv, I usually give it the same name as my app
$ mkvirtualenv &lt;VIRTUALENV_NAME&gt;

# The virtualenv will be activated automatically.
# You can deactivate it like this
$ deactivate

# to activate a virtualenv, or change which one is active, do this
$ workon &lt;VIRTUALENV_NAME&gt;</pre>
<p>One very helpful command you can use now is pip freeze. Pip freeze lists all available Python packages and their versions. It will let you easily see what has been installed. Try these commands out. You will see just how many packages have already been installed system-wide by Ubuntu. You will also see that your virtualenv is isolated from the rest of the system, and doesn&#8217;t have much installed in it yet.</p>
<pre>$ deactivate
$ pip freeze
$ workon &lt;VIRTUALENV_NAME&gt;
$ pip freeze</pre>
<h2>Django</h2>
<p>Installing Django is very simple. Make sure the virtualenv is activated. This is the last time I will remind you to activate.</p>
<pre># install the newest version of Django
$ pip install django

# also install docutils, which is used by the django admin
$ pip install docutils

# If you want to test django, start a new project and run it
$ django-admin.py startproject &lt;APP_NAME&gt;
$ cd &lt;APP_NAME&gt;
# make manage.py executable
$ chmod +x manage.py
# start the dev server
$ ./manage.py runserver 0.0.0.0:8000</pre>
<h2>PIL / Pillow</h2>
<p><a href="http://www.pythonware.com/products/pil/">PIL</a> is the Python imaging library. It is needed if your application is going to do anything involving at all involving images. Even if you simply allow user to upload images, you will need it. There is a drop in replacement available called <a href="http://pypi.python.org/pypi/Pillow/">Pillow</a>. I&#8217;ve never had problems with either one, but some people have problems with PIL. If you don&#8217;t know, just choose Pillow. Whichever one you choose, you will need the same set of prerequisite C libraries. If you don&#8217;t install these, then PIL might fail if a user tries to upload a jpg, or you try to perform certain image operations.</p>
<pre># install libraries
$ sudo apt-get install libjpeg8-dev libfreetype6-dev zlib1g-dev

# choose ONE of these
$ pip install pillow
$ pip install pil</pre>
<h2>Databases MySQL / PostgreSQL</h2>
<p>It&#8217;s up to you to choose your database. I prefer <a href="http://www.mysql.com/">MySQL</a> because it is easier. The Django devs prefer <a href="http://www.postgresql.org/">PostgreSQL</a> because it is more robust. You can learn to configure the databases using their respective documentation. It&#8217;s also up to you to edit the Django settings.py file to point at the appropriate database server. If you choose MySQL, you should configure it so that utf8 is always the default character set, utf8_general_ci is the default collation, and that InnoDB is the default storage engine.</p>
<pre># do this to go with Postgres
$ sudo apt-get install postgresql libpq-dev
$ pip install psycopg2

# do this to go with MySQL
$ sudo apt-get install mysql-server libmysqlclient-dev
$ pip install MySQL-Python</pre>
<p>Whichever database you choose, you will have to create a database and a user for your application to use. Then you will have to make sure that the user has full permissions on that database.</p>
<h2>South</h2>
<p><a href="http://south.aeracode.org/">South</a> is a mandatory part of every Django project as far as I am concerned. It manages schema changes to your database about as well as can be expected, and makes life much easier in general.</p>
<pre>$ pip install south

# add south to the INSTALLED_APPS in your settings.py
$ vim &lt;YOUR_APP&gt;/settings.py
INSTALLED_APPS = 
    ...
    'south',
    ...</pre>
<h2>memcached</h2>
<p>Just about every web site can benefit from having memcached. It creates a key:value store directly in memory that is very fast and easy. This can be used to store information to reduce database queries and increase performance. There have been many different libraries and modules for memcached, but PyLibMC is presently the preferred choice.</p>
<pre># install memcached server and library
$ sudo apt-get install memcached libmemcached-dev

# install pylibmc
$ pip install pylibmc

# edit the CACHES setting in your project's settings.py
$ vim &lt;YOUR_APP&gt;/settings.py
CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache',
        'LOCATION': '127.0.0.1:11211',
    }
}</pre>
<h2>Asynchronous Task Execution</h2>
<p>Almost every site can benefit from asynchronous task execution. Even if your site isn&#8217;t big enough to make it a necessity for scaling and performance, why not do it? It&#8217;s very easy to set it up, and requires only free software.</p>
<p>What is asynchronous task execution? Let&#8217;s say you have a simple contact form. If you call send_email from the contact form view, then the user who submitted the form will not receive an HTTP response until the email has been sent. Their browser will sit there spinning while the server works. It will also tie up one of your web server threads. To make matters worse, if there is an email error, it will return that error to the user.</p>
<p>What you really want to do is send the user to a thank you page immediately after they submit. Then you can send the email some time later without tying up a web server. If there is an error, you can keep retrying it without bothering the user. To do this we use a Python package called <a href="http://celeryproject.org/">celery</a>.</p>
<p>Celery requires a few pieces to work. First, it needs celery workers. These are the programs that actually do the work, such as sending the emails. Next it needs a message queuing server. This is where the celery workers look to see if there is any work they should be doing. For this you should use <a href="http://www.rabbitmq.com/">RabbitMQ</a>.</p>
<p>There is also celerycam, which will monitor celery by taking snapshots every few seconds. This will allow you to see the state of what celery is doing from the Django admin interface. Lastly, we need a place to store results if any celery tasks produce them. For that we will just use the existing MySQL or PostgreSQL database.</p>
<h2>RabbitMQ</h2>
<p>When you install RabbitMQ you also have to create a user and grant them permissions on a virtual host. You can pick whatever username, password, and vhost name you like, but I always use the name of my app for all three.</p>
<pre>$ sudo apt-get install rabbitmq-server
$ sudo rabbitmqctl add_user &lt;RABBIT_USER&gt; &lt;RABBIT_PASSWORD&gt;
$ sudo rabbitmqctl add_vhost &lt;RABBIT_VHOST&gt;
$ sudo rabbitmqctl set_permissions -p &lt;RABBIT_VHOST&gt; &lt;RABBIT_USER&gt; ".*" ".*" ".*"</pre>
<h2>Celery</h2>
<p>Installing celery itself is a one liner, but it requires a lot of modifications to the Django settings file to get it working properly.</p>
<pre>$ pip install django-celery

$ vim &lt;YOUR_APP&gt;/settings.py

# add djcelery to INSTALLED_APPS
INSTALLED_APPS = 
    ...
    'djcelery',
    ...

# add these settings
BROKER_URL = "amqp://&lt;RABBIT_USER&gt;:&lt;RABBIT_PASSWORD&gt;@localhost:5672/&lt;RABBIT_VHOST&gt;"
CELERY_RESULT_BACKEND = "database"

# choose the setting that matches your database of choice
CELERY_RESULT_DBURI = "mysql://&lt;DB_USER&gt;:&lt;DB_PASSWORD&gt;@localhost/&lt;DB_NAME&gt;"
CELERY_RESULT_DBURI = "postgresql://&lt;DB_USER&gt;:&lt;DB_PASSWORD&gt;@localhost/&lt;DB_NAME&gt;"

# put these two lines at the very bottom of the settings file
import djcelery
djcelery.setup_loader()</pre>
<p>To test celery you can start up the celery daemon using a management command. If your application is going to have recurring tasks, you should enable events and celerybeat. Otherwise, you can ignore those options.</p>
<pre># start celery with Beat and Event
$ ./manage.py celeryd -B -E

# start celery normally
$ ./manage.py celeryd

# press Ctrl+C to quit celery once you see it is working</pre>
<h2>gunicorn</h2>
<p>When you want to serve a modern Python web application, you use a thing called the <a href="http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface">web server gateway interface</a> (WSGI). That is how your application will talk to the web server. There are a lot of choices when it comes to using WSGI. <a href="http://httpd.apache.org/">Apache</a> with <a href="http://code.google.com/p/modwsgi/">mod_wsgi</a> is the old trustworthy option. <a href="http://projects.unbit.it/uwsgi/">uWSGI</a> is also very popular. I personally prefer <a href="http://gunicorn.org/">Gunicorn</a> because it works extremely well, and runs great out of the box without any configuration.</p>
<pre>$ pip install gunicorn

# add gunicorn to INSTALLED_APPS
$ vim &lt;YOUR_APP&gt;/settings.py
INSTALLED_APPS =
    ...
    'gunicorn',
    ...</pre>
<p>Like celery, you can test Gunicorn by running it from a management command. The Gunicorn management command has many command line parameters. You can read about the options in the <a href="http://docs.gunicorn.org/en/latest/configure.html">Gunicorn documentation</a>. Personally, the only options I use are to set Gunicorn to use four workers and to enable <a href="http://www.gevent.org/">gevent</a>. You will see more about this in the next section.</p>
<pre>$ ./manage.py run_gunicorn -w 4 -k gevent

# pres Ctrl+C to exit Gunicorn once you see it is working</pre>
<h2>Supervisor</h2>
<p>You may have noticed by now that Ubuntu is very clever in the way it handles servers. When you install MySQL with apt-get it immediately starts it with a default configuration. The same goes for RabbitMQ, memcached, SSH, and almost every other such server. If the machine reboots, these services will start themselves automatically. We can trust the distribution to take care of this for us.</p>
<p>But we have a problem now. We need to start Gunicorn and celery as services, but Ubuntu won&#8217;t help us with things we didn&#8217;t install with apt-get. One way to solve this problem is to write upstart or init.d scripts for these services. That will work, but it&#8217;s a pain in the ass. Those kinds of scripts are not simple to write, and are worse to maintain. Luckily <a href="http://supervisord.org/">supervisor</a> exists.</p>
<p>Supervisor is installed with apt-get, so it will start automatically. We give supervisor very simple configuration files for any further services we would like it to manage, and it will start those up for us. It has the added benefit that it can restart any service it is managing in the case of failure. If Gunicorn crashes, it will come right back without us having to do anything. Because of this feature, some people choose to manage all their services under supervisor. I do not do this because it is extra work, and it is very rare that it will help you. If something like MySQL crashes, odds are it will not be successfully or safely restarted by supervisor.</p>
<p>Installing supervisor is as simple as apt-get, but configuring it is another matter. We need to create a configuration file for each service that supervisor manages. These configuration files must be located in /etc/supervisor/conf.d/ and must have a name with the conf extension. I have included here the full contents of my three supervisor configuration files, but have only documented the first one, as they are so similar.</p>
<pre>$ sudo apt-get install supervisor</pre>
<pre># contents of /etc/supervisor/conf.d/celeryd.conf

# the name of this service as far as supervisor is concerned
[program:celeryd]

# the command to start celery
command = /home/&lt;USERNAME&gt;/.virtualenvs/&lt;VIRTUALENV_NAME&gt;/bin/python /home/&lt;USERNAME&gt;/&lt;APP_NAME&gt;/manage.py celeryd -B -E

# the directory to be in while running this
directory = /home/&lt;USERNAME&gt;/&lt;APP_NAME&gt;

# the user to run this service as
user = &lt;USERNAME&gt;

# start this at boot, and restart it if it fails
autostart = true
autorestart = true

# take stdout and stderr of celery and write to these log files
stdout_logfile = /var/log/supervisor/celeryd.log
stderr_logfile = /var/log/supervisor/celeryd_err.log</pre>
<pre># contents of /etc/supervisor/conf.d/celerycam.conf
[program:celerycam]
command = /home/&lt;USERNAME&gt;/.virtualenvs/&lt;VIRTUALENV_NAME&gt;/bin/python /home/&lt;USERNAME&gt;/&lt;APP_NAME&gt;/manage.py celerycam
directory = /home/&lt;USERNAME&gt;/&lt;APP_NAME&gt;
user = &lt;USERNAME&gt;
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/celerycam.log
stderr_logfile = /var/log/supervisor/celerycam_err.log</pre>
<pre># contents of /etc/supervisor/conf.d/gunicorn.conf
[program:gunicorn]
command = /home/&lt;USERNAME&gt;/.virtualenvs/&lt;VIRTUALENV_NAME&gt;/bin/python /home/&lt;USERNAME&gt;/&lt;APP_NAME&gt;/manage.py run_gunicorn -w 4 -k gevent
directory = /home/&lt;USERNAME&gt;/&lt;APP_NAME&gt;
user = &lt;USERNAME&gt;
autostart = true
autorestart = true
stdout_logfile = /var/log/supervisor/gunicorn.log
stderr_logfile = /var/log/supervisor/gunicorn_err.log</pre>
<p>You will notice the command for each of the supervisor configurations is strange. Instead of just running manage.py directly, we are specifically calling the python interpreter located inside of our virtualenv. There is no way for supervisor to easily activate itself the way we activate in our shell with the workon command. By specifically using the python interpreter from the virtualenv instead of the system version, celery and gunicorn will have the correct path settings, and will use the packages within the the virtualenv. Also, note the celeryd and gunicorn command line parameters we had discussed earlier to enable beat, event, gevent, etc.</p>
<p>To make supervisor recognize the new configuration files, we must restart it. It&#8217;s also pretty obvious from the example blow how to manually control the services that supervisor manages.</p>
<pre># restart supervisor itself
$ sudo service supervisor restart

# restart/stop/start all services managed by supervisor
$ sudo supervisorctl restart all
$ sudo supervisorctl stop all
$ sudo supervisorctl start all

# restart just celeryd
$ sudo supervisorctl restart celeryd

# start just gunicorn
$ sudo supervisorctl start gunicorn</pre>
<h2>Static and Media</h2>
<p>There is a great deal of confusion about static and media in Django. It is partially because the separation of the two was not very clear in earlier releases. This has since been fixed, and the static files system has been completely reworked. While the problem is solved in  the current versions, the big changes may have added to the confusion. Allow me to help.</p>
<p>Static files are files that you would put into your repository that are not code. These are almost always css, jss, and image files. Your favicon would also be a static file. This is a file that you make, must be served to web browsers, but does not change unless you update your application.</p>
<p>Media files are files that are also served statically, but they were not made by you. They were uploaded by users. So on a site like YouTube, the YouTube logo in the top left would be a static file, but the actual videos themselves would be media. On Flickr, the css and the login buttons would be static, but the photos uploaded by users are media.</p>
<p>For media files we must simply take files that users upload, put them in a folder, and then serve the files in that folder. For static files we have a slightly trickier issue because they are not so easily located. The django admin keeps its static files in one place. You put your static files in another place. Maybe you pip install another third party module that includes some static files. In this case, you run a management command to collect the static files to a single folder from which they will be served.</p>
<pre># Create directories to hold static and media
sudo mkdir /var/www
sudo mkdir /var/www/static
sudo mkdir /var/www/media

# set permissions on these directories
sudo chown -R &lt;USERNAME&gt;:www-data /var/www

$ vim &lt;YOUR_APP&gt;/settings.py

# these settings are explained below
MEDIA_ROOT = '/var/www/media/'
MEDIA_URL = '/media/'
STATIC_ROOT = '/var/www/static/'
STATIC_URL = '/static/'

# run this whenever static files are changed
$ ./manage.py collectstatic</pre>
<p>In the django settings file there are four settings. MEDIA_ROOT, MEDIA_URL, STATIC_ROOT, and STATIC_URL. The ROOT settings are the local directories where the files are located. The URL settings are the URLs where these files will be served. Assume we have a file named css/main.css Using the above example, the file will be located in /var/www/static/css/main.css after it is collected. It will be served from the URL http://yourdomain.com/static/css/main.css.</p>
<p>One more benefit of the static system is that you can use pip to add static files to your project. For example, you can pip install <a href="http://pypi.python.org/pypi/django-staticfiles-jquery">django-staticfiles-jquery</a> and <a href="http://pypi.python.org/pypi/django-staticfiles-bootstrap/2.2.2">django-staticfiles-bootstrap</a> to automatically put jquery and boostrap into your static files when you run collectstatic.</p>
<h2>Nginx</h2>
<p>This brings us to the final piece of the puzzle. How exactly are these static files served? Gunicorn handles serving all the dynamically generated pages of our application, but it doesn&#8217;t know anything about these static files. The Django runserver will do some magic to handle these files to make development easier, but once you enter production and set DEBUG=False, you no longer have this luxury. That is why we put <a href="http://nginx.com/">Nginx</a> as our web server out in front of Gunicorn. It will serve all the static files, and also ask Gunicorn to handle any requests it doesn&#8217;t know what to do with.</p>
<pre># install nginx
$ sudo apt-get install nginx</pre>
<p>Much like Apache, Nginx uses two folders for configuration. There is /etc/nginx/sites-available/ and /etc/nginx/sites-enabled/. You put all your nginx configuration files into the sites-available directory. Then if you want a site to be active, you create a symlink to that file from the sites-enabled directory. You have to restart nginx after any configuration changes. Because Ubuntu starts nginx with a default configuration when you install it, you must first remove the symlink to that default configuration.</p>
<pre># remove the default symbolic link
$ sudo rm /etc/nginx/sites-enabled/default

# create a new blank config, and make a symlink to it
$ sudo touch /etc/nginx/sites-available/&lt;YOUR_APP&gt;
$ cd /etc/nginx/sites-enabled
$ sudo ln -s ../sites-available/&lt;YOUR_APP&gt;

# edit the nginx configuration file
$ vim /etc/nginx/sites-available/&lt;YOUR_APP&gt;</pre>
<p>Here is what the nginx configuration file should look like</p>
<pre># define an upstream server named gunicorn on localhost port 8000
upstream gunicorn {
    server localhost:8000;
}

# make an nginx server
server {
    # listen on port 80
    listen 80;

    # for requests to these domains
    server_name &lt;YOUR_DOMAIN&gt;.com www.&lt;YOUR_DOMAIN&gt;.com;

    # look in this directory for files to serve
    root /var/www/;

    # keep logs in these files
    access_log /var/log/nginx/&lt;YOUR_APP&gt;.access.log;
    error_log /var/log/nginx/&lt;YOUR_APP&gt;.error.log;

    # You need this to allow users to upload large files
    # See http://wiki.nginx.org/HttpCoreModule#client_max_body_size
    # I'm not sure where it goes, so I put it in twice. It works.
    client_max_body_size 0;

    # THIS IS THE IMPORTANT LINE
    # this tries to serve a static file at the requested url
    # if no static file is found, it passes the url to gunicorn
    try_files $uri @gunicorn;

    # define rules for gunicorn
    location @gunicorn {
        # repeated just in case
        client_max_body_size 0;

        # proxy to the gunicorn upstream defined above
        proxy_pass http://gunicorn;

        # makes sure the URLs don't actually say http://gunicorn 
        proxy_redirect off;

        # If gunicorn takes &gt; 5 minutes to respond, give up
        # Feel free to change the time on this
        proxy_read_timeout 5m;

        # make sure these HTTP headers are set properly
        proxy_set_header Host            $host;
        proxy_set_header X-Real-IP       $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}</pre>
<p>Restart nginx and your server is now running and serving your django application perfectly!</p>
<pre># restart nginx
$ sudo service nginx restart</pre>
<h1>Conclusion</h1>
<p>I&#8217;m sure there are going to be errors in this no matter how much I proofread. I also fully admit that there is always more to learn. I welcome any suggested fixes or improvements to any part of this. Just leave a comment below.</p>
<p>I also hope this saves someone some money by letting them run their site on a cheap Linux host instead of a managed host. Most of all I hope it gets some people to view their application as not just the one piece they wrote, but as a whole made up of many separate working parts. And that those other parts are not to be outsourced, but to be embraced. When you control them, you can solve problems with them.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/complete-single-server-django-stack-tutorial/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Summer Camp Politics</title>
		<link>http://www.apreche.net/summer-camp-politics/</link>
		<comments>http://www.apreche.net/summer-camp-politics/#comments</comments>
		<pubDate>Thu, 10 May 2012 03:51:32 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1330</guid>
		<description><![CDATA[Gather round and listen to this true tale of summer camp. It&#8217;s actually true. I swear this is not a lead in to sexual innuendo. It was generic day camp, not band camp. At this day camp we played a &#8230; <a href="http://www.apreche.net/summer-camp-politics/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Gather round and listen to this true tale of summer camp. It&#8217;s actually true. I swear this is not a lead in to sexual innuendo. It was generic day camp, not band camp.</p>
<p>At this day camp we played a lot of four square. The thing was, we played it inside a cabin. The cabin was square. There was no furniture. There were built-in benches all around the inner edge. It had a roof to block the rain. The square was already painted very clearly on the wooden floor by campers of years past. It was an arena that beckoned for the red Voit.<span id="more-1330"></span></p>
<p>However, because there were walls in this cabin all sorts of crazy situations developed. Is it in or out if it bounces off the benches or the ceiling? What if it goes out of the cabin? Are double taps and other cheap maneuvers permitted? What if someone sitting on a bench interferes?</p>
<p>In all the time of this summer camp, nobody had bothered to actually solve these problems. Nobody took games are seriously as I did, and still do. The solution in place was simply that whoever was in the ace position had the serve and dictated the rules. The game changed rules every time the serve changed hands. The basic idea was that when you earned the serve you would choose rules favorable to yourself, so that you would keep the serve for as long as possible. It was the simple children&#8217;s logic of winner&#8217;s ball.</p>
<p>The other kids didn&#8217;t want a fair game of skill. They didn&#8217;t want to have to earn victory. They wanted victory handed to them on a silver platter. To them it had been a game of using trickery, cheap maneuvers, and hax. I, on the other hand, had always played honestly. I felt righteous, even in defeat. I wouldn&#8217;t use a bullshit double-tap or spike, even when it was permitted. I told myself I only lost because they were all cheap and/or cheating. I was always quickly eliminated.</p>
<p>One rainy day most activities were canceled, and we played four square for many hours. Perhaps for the first time, I became the ace. I had begrudgingly played by their rules until now, but things were about to change. In about five minutes I rewrote the rules of the game to be not completely broken and unfair. I laid down the law on all sorts of exceptional situations that had occurred, and could theoretically occur. It was a four square revolution.</p>
<p>Now you might think my new regime would have pissed everyone off. They would have moaned and groaned because of the change. They would have called me names and not obeyed my rulings. I even expected it at the time. I was happy to just play a fair game, even if it were to last only a single round.</p>
<p>After I laid down the law I actually won a few rounds as the other kids adjusted out of habits that were now illegal. Of course I was eventually eliminated from the square, and the king moved to the ace position. It was time for a new ruler to lay down the law.</p>
<p>Two words did he then utter.</p>
<p>&#8220;Scott&#8217;s Rules&#8221;</p>
<p>You may or may not have to play the game to win the game. But once you are in charge, you can dismantle the game. Obviously the dictatorship of four square is relatively simple, but it is often frightening how often schoolyard politics resemble world politics. Only those with the power in the system can fix the system. If those in power truly hated the state of the game, they could change it. The fact that politicians not only play the crooked game, but keep the game crooked, means that they prefer the crooked game. That is an undeniable fact. They may say they hate the system, but if they do not fix it, then they support it.</p>
<p>Remember, if they are in power, that means they have won the game of politics at least once, and probably many times. Why would they change the rules of this unfair and corrupt game when they themselves are already so good at it? Fixing the system likely means removing themselves from power. Anyone like myself who would change the game can not possibly get into a position to do so. Our refusal to cross ethical boundaries makes it next to impossible to attain a position of power.</p>
<p>Some politicians are more corrupt than others. Some are clearly more preferable than others. Yet, any one that plays the game of politics, and does not at least attempt to fix it or even speak out against it, is, in my eyes, a corrupt piece of shit. The level of stink may vary, but shit is shit.</p>
<p>Now, my rules didn&#8217;t last forever. They were not written down, and I only taught them once. Some rules were forgotten or misinterpreted. Often kids would reach the ace and say &#8220;Scott&#8217;s Rules plus spike on serve,&#8221; or some other nonsense. They knew my rules made the game more fair and more fun, but they could not rid themselves of corruption when in a position of power. They wanted to win, and had no qualms about modifying the rules to their advantage. It wasn&#8217;t enough to fix the system once. It had to be constantly maintained lest it fall back into disrepair.</p>
<p>Look, ye mighty.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/summer-camp-politics/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anything that is Digital has no National Borders</title>
		<link>http://www.apreche.net/anything-that-is-digital-has-no-national-borders/</link>
		<comments>http://www.apreche.net/anything-that-is-digital-has-no-national-borders/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 23:08:21 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Opinion]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1327</guid>
		<description><![CDATA[Trying to remove the world from the world wide web is impossible. <a href="http://www.apreche.net/anything-that-is-digital-has-no-national-borders/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>With the battle raging over SOPA and PIPA, the copyright war is as hot as it has ever been. The same points have been repeated ad nauseam, but there is one aspect that is not emphasized enough. SOPA and PIPA supporters often claim that these laws only affect sites outside the United States. Even if that were true, that&#8217;s a point against these laws, not for them! The national segregation on the part of media companies needs to end. Whether they like it or not, anything that is digital ignores all borders, and now is the time to stop fighting it.<span id="more-1327"></span></p>
<p>In the days before the Internet, national borders were solid walls. If a movie was released in country A, and you lived in country B, it was almost impossible to see it. Maybe you could see it during a vacation in country A. Your only realistic hope was for someone to physically import the film. Even with VHS that would only help you if you spoke the language of the other country, or someone with equipment and time generously subtitled it. Without that, you simply had to wait and hope some local company would license and redistribute the movie in your home country. Any work that managed to achieve international distribution was nothing short of a miracle.</p>
<p>It wasn&#8217;t all bad. Miracles do happen. The most popular of things did get released internationally. Beatles albums, for example, were available in many countries.  Disappointingly, they couldn&#8217;t leave well enough alone. The <a title="UK Release of Rubber Soul" href="https://en.wikipedia.org/wiki/Rubber_Soul#UK_release" target="_blank">UK release</a> of Rubber Soul had different tracks from the <a title="North American release of Rubber Soul" href="https://en.wikipedia.org/wiki/Rubber_Soul#North_American_release" target="_blank">North American release</a>. The same was true for almost every international release across all media in those days. Completely unchanged releases across regions were the true miracles.</p>
<p>Why would they do this? The producers had some ideas, that may or may not be true, about what would appeal to different cultures in different countries. If you have enough money to produce different versions of your art for different audiences, and your ideas about cultural preferences are correct, why wouldn&#8217;t you segregate to sell more copies? When playing a live concert, doesn&#8217;t a musician play different songs in different cities? Why wouldn&#8217;t your album have different tracks in different countries? As long as every country gets every song, I really don&#8217;t see a problem with having them reconfigured onto different discs in different orders.</p>
<p>And there wasn&#8217;t much of a problem. The vast majority of fans in North America had no idea that the tracks were different in the UK, and vice versa. They got away with it so well for so long, that they still continue this behavior today. It is now a humongous problem. How can you possibly have the exact same business strategy as fifty years ago, and not even realize there&#8217;s a problem?</p>
<p>Today you absolutely can not get away with these kinds of edits. Everyone who cares will find out immediately. When video games and comic books are censored for different markets, articles on the web instantly crop up listing in excruciating detail every single difference between the versions. When video games are released with different box art, or books have different cover art, everyone ends up seeing every version. Even board games are not immune to this. It is impossible to keep the secret, but they still try.</p>
<p>Not only is it impossible to keep the secret, but heaven help you if one country gets more than another. The DVD from one country has bonus features not released in the other? It will take maybe two seconds for people to flood the post office and start exporting the superior version.</p>
<p>Even worse is when companies try to set different prices in different countries. A movie on DVD in Japan might cost $40+ while the same DVD in the US is $15 at most. Even with the cost of shipping, importing DVDs from the US is definitely a money saving move. When international shipping is a cost savings, something is extremely wrong.</p>
<p>I&#8217;ve also seen cases where simply knowing that their country is being overcharged causes people to stop buying. In Australia video game prices are famously much higher than in other countries. Some people import games, but many just don&#8217;t buy them at all. Even if they could afford to buy them, they don&#8217;t. They know the international prices. They know they are being overcharged, so they buy fewer games.</p>
<p>There have been a few attempts to technologically prevent importing and exporting of media. All of them are futile. DVD region codes have been useless for a very long time. Even now with the Nintendo 3DS being region locked a hack will definitely appear, if it hasn&#8217;t already. If it doesn&#8217;t, people will import the console itself. Creating this region locking technology must cost companies time and money. They must be better off not fighting such a futile battle. Heck, you regularly see entire arcade machines that are technically not supposed to cross international borders. If such big machines can make the trip, there&#8217;s no stopping digital copies of anything.</p>
<p>The most hilarious is when you go on Spotify and it lists the top tracks. Any songs not available in your country are listed, but grayed out. What do they think happens? Everyone immediately will go to The Pirate Bay and type in the names of these artists. Why do they list them in gray when they could just remove them from the list entirely? My guess is that it is an intentional design decision by Spotify. They probably don&#8217;t agree with the region locking and are forced into it by the record companies. They know that you are going to pirate those songs, so they keep them in the list to help those artists create an international fanbase.</p>
<p>Here is one particularly egregious example concerning My Little Pony: Friendship is Magic. <a title="Clarification From Hasbro About Regional DVD Sales and Episode Releases " href="http://www.equestriadaily.com/2012/01/clarification-from-hasbro-about.html" target="_blank">Clarification From Hasbro About Regional DVD Sales and Episode Releases</a>.  You have a product that has become internationally popular because it was illegally, and inevitably, distributed worldwide on the Internet. Now you completely fail to have it legally available in any form. Your customers who want to give you money are left with almost no choice but to pirate it.</p>
<p>Could they wait for the legal release? Yes, but there&#8217;s no guarantee if or when it will happen. There&#8217;s also no guarantee it won&#8217;t be modified and ruined by poor translation or censorship. If someone is forced to wait, there are so many other entertainment options they are guaranteed to look elsewhere. Most likely they will forget about you, and now you&#8217;ve really lost a sale. At least if they pirate they might become a huge fan and remember you when you finally get around to a legal release, or buy your other merchandise.</p>
<p>Now famous is the story of <a title="Gabe Newell on piracy and Steam’s success in Russia" href="http://www.pcgamer.com/2011/10/25/gabe-newell-on-piracy-and-steams-success-in-russia/" target="_blank">how Valve software reduced game piracy in Russia</a>. Russia is a country where piracy rates are through the roof. Lots of people don&#8217;t even bother releasing their products there because piracy is so widespread they will make almost no sales. Then how come Valve made sales? Did they use magic? No, they simply released the exact same product in Russia at the exact same time they released in every other country on Earth, and let them pay in rubles. A true global release. And of course, it works.</p>
<p>Russia is a classic chicken and egg situation. Not enough things being available lead to pirating. Pirating lead to less things being available. That lead to more pirating. The only way to break the cycle is to make things legally available. Valve broke the cycle. Can the bone-headed old world companies ever do the same? They haven&#8217;t yet, and I doubt they ever will.</p>
<p>In this day and age, even time zones matter. If you have a midnight release, guess what? It&#8217;s midnight on the East Coast of the USA three hours before midnight on the West Coast. Your product can be uploaded and transferred to the entire world before the Central Time Zone release, let alone the Pacific. If it&#8217;s a midnight release in the East, then it&#8217;s a 10PM release in the West. You have no choice in this matter. The people of California aren&#8217;t going to wait three hours. You had better open your doors before they close their wallets.</p>
<p>What I find most hilarious is when web sites try to restrict themselves to one geographic region. Welcome to new social network X, now available in Canada. Uh, dude. It&#8217;s the <em>world</em> wide web. When you put something on the web, it&#8217;s available world wide. You can&#8217;t keep anyone out. Look at how hard Hulu, Netflix, and BBC fail to keep people in different countries from getting access, and it never works. Lots of online games in South Korea try unsuccessfully to keep out players from other countries. Why do they even try?</p>
<p>There is always an issue of translation cost. If there is any language in your product, you must localize it for each market. Each localization costs money. And what if a Swahili translation is a big economic risk considering how few sales you are likely to get? What can you do about that?</p>
<p>Don&#8217;t do anything. Don&#8217;t do the Swahili translation. But you should still release it in Swahili speaking nations, and include every localization that you have available. If someone buys it and does a fan translation, now you have discovered, or even created, some fans. Maybe by the time the sequel is done the risk of translating to Swahili will be much lower. Maybe you will know for sure that it&#8217;s not worth the cost to translate into Swahili, but hey, you sold three extra copies in English and two in French. Five is more than zero, and it cost you nothing extra to make it available to them.</p>
<p>Another thing I&#8217;ve noticed is companies that feel an absolute necessity to market something. They can&#8217;t release a product unless they market the hell out of it, and they really care about the timing of the marketing coinciding with the release.</p>
<p>First of all, digital marketing is also international. If you advertise on the web, you&#8217;ve already advertised to the world. A big part of the problem is when companies unintentionally create demand in countries they aren&#8217;t serving. If I make you want something very badly, and then don&#8217;t offer it to you legally, of course you are going to pirate it if that is your only available option.</p>
<p>Also, there is nothing wrong with making something available without marketing it. Ok, you only made two sales in Argentina because you didn&#8217;t market there. Who cares? You made two sales! It cost you nothing to make it available to them. That&#8217;s only positive.</p>
<p>Lastly, the timing means nothing. Even Apple seems to get this one wrong. You released in Argentina a year ago. Now you decide you want to start marketing there. The people will not care that your product was released so long ago. It&#8217;s not food. It doesn&#8217;t spoil. Your advertising will be no less effective. In fact, some of the biggest advertisers are food companies like McDonald&#8217;s, Pepsi, and Coca-Cola. Their advertising still works on products that were released decades ago. Advertising your one year old product will be just fine.</p>
<p>Here&#8217;s what it all comes down to. In terms of selling any product that can take a digital form, every release is a worldwide simultaneous release, whether you like it or not. If you fail to treat it as such, you will simply be hurting yourself and nobody else. Whatever it is you are selling, you need to make the exact some product available in every single country on Earth at the exact same second at the exact same price, no exceptions, period. If the product is digital, it costs nothing extra whatsoever to simply make it available. Do it.</p>
<p>Trying to remove the world from the world wide web is impossible. It&#8217;s simultaneously baffling and hilarious to see so many people try so hard to achieve this impossible goal. There has to be more than one company on this planet who is willing to end this charade.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/anything-that-is-digital-has-no-national-borders/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: Programatically Post a Status Update to Your Facebook Page</title>
		<link>http://www.apreche.net/tutorial-programatically-post-a-status-update-to-your-facebook-page/</link>
		<comments>http://www.apreche.net/tutorial-programatically-post-a-status-update-to-your-facebook-page/#comments</comments>
		<pubDate>Mon, 25 Jul 2011 17:00:31 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1279</guid>
		<description><![CDATA[In my last post, To OAuth or Not to OAuth, I said I would write a complete tutorial on how to use the Facebook API to post status updates to your own Facebook page. This is that tutorial. Get ready, &#8230; <a href="http://www.apreche.net/tutorial-programatically-post-a-status-update-to-your-facebook-page/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In my last post, <a title="To OAuth or Not to OAuth" href="http://www.apreche.net/to-oauth-or-not-to-oauth/">To OAuth or Not to OAuth</a>, I said I would write a complete tutorial on how to use the Facebook API to post status updates to your own Facebook page. This is that tutorial. Get ready, it&#8217;s a doozy.<span id="more-1279"></span></p>
<h2>Definitions</h2>
<p>Before we begin there are some definitions I have to set down.</p>
<dl>
<dt>Facebook Account</dt>
<dd>The actual Facebook account you use to talk to friends and family.</dd>
<dt>Facebook Page</dt>
<dd>A separate page you have setup for your brand or online community.</dd>
<dt>Facebook Application</dt>
<dd>An application you create which is basically just an set of IDs you need to connect to the Facebook API.</dd>
</dl>
<h2>Setup</h2>
<p>Before we begin you have to create your facebook account, page and application. I&#8217;ll assume you already have an account, or know how to create one. That&#8217;s clearly outside the scope of this tutorial. Make sure you remain logged into your Facebook account throughout this entire process.</p>
<p>If you don&#8217;t already have one, you need to create a Facebook page. Go to <a title="https://www.facebook.com/pages/create.php" href="https://www.facebook.com/pages/create.php">https://www.facebook.com/pages/create.php</a>, and follow the instructions. When you are all done you will end up looking at your new page. It will have a URL that will have the following format.</p>
<pre>https://www.facebook.com/pages/PAGE_NAME/PAGE_ID_NUMBER</pre>
<p>Save the PAGE_NAME and PAGE_ID_NUMBER. If you already have a page, visit it and look at the URL for the name and/or id number. Make sure that your Facebook account has permission to post status updates on that page. I&#8217;ve only tested this on pages where my account is the page administrator. Your mileage may vary otherwise, but I see no reason it wouldn&#8217;t work as long as you have the necessary permissions.</p>
<p>The next step is to create a Facebook application. To do that go to <a title="https://www.facebook.com/developers/createapp.php" href="https://www.facebook.com/developers/createapp.php">https://www.facebook.com/developers/createapp.php</a> and follow the instructions. You will go through a configuration process. You can leave all settings as the defaults. Just save the Application ID and Application Secret, and you will be good to go.</p>
<p style="text-align: center;"><a href="http://www.apreche.net/wp-content/uploads/2011/07/createapplication.png" target="_blank"><img class="size-full wp-image-1284 aligncenter" title="Creating a Facebook Application" alt="Creating a Facebook Application" src="http://www.apreche.net/wp-content/uploads/2011/07/createapplication.png" width="971" height="335" /></a></p>
<h2>Get the Access Tokens Through OAuth</h2>
<p>Now it&#8217;s time for the tricky parts. You have to give the application permission to access your account. Take the URL below and replace both instances of APP_ID with the ID of the application you just made.</p>
<pre>https://www.facebook.com/dialog/oauth?client_id=APP_ID&amp;
redirect_uri=http://www.facebook.com/appcenter/APP_ID&amp;scope=manage_pages,offline_access,publish_stream</pre>
<p>Visit this URL in your browser and you will get a dialog box that will ask you whether to allow or deny granting permissions on your account to the application. The page needs to redirect somewhere after you click allow, and it will only allow you to redirect to a page your application owns. That&#8217;s why we put the URL of your application&#8217;s profile page as the redirect_uri.</p>
<p>The three permissions we are granting are manage_pages, offline_access, and publish_stream. Manage_pages grants the application access to pages which your account has access to. Offline_access means that the application will get an access token that never expires so we never have to do this complicated process ever again. Publish_stream allows the application to post new updates to your account, or any other place your account is able to post updates to, including the page we just created.</p>
<p>Click the allow button. Immediately go to the location bar of your browser and copy and paste the URL to a text editor. Do not lose it. You will see that the URL looks something like this.</p>
<pre>https://www.facebook.com/apps/application.php?id=APP_ID
&amp;code=CRAZY_LONG_CODE</pre>
<p>That crazy long code is the magic we need. Take that code and use it to create yet another URL in the format that follows. Replace APP_ID with the Application ID as usual. Replace APP_SECRET with the Application Secret. Lastly, put that CRAZY_LONG_CODE where it belongs. Paste the resulting gigantic URL into the location bar of your browser and visit it.</p>
<pre>https://graph.facebook.com/oauth/access_token?client_id=APP_ID
&amp;redirect_uri=https://www.facebook.com/apps/application.php?
id=APP_ID&amp;client_secret=APP_SECRET&amp;code=CRAZY_LONG_CODE</pre>
<p>If you did everything right you should now be looking at a big beautiful access_token. We will call this the account access token. It gives your facebook application permission to access your account. If you just want to post status updates to your personal account, you can take this access token to the next section. Otherwise, proceed to get the page access token.</p>
<p>In order to get the page access token, we need to visit yet another URL, it looks like this.</p>
<pre>https://graph.facebook.com/USER_ID/accounts/?
access_token=ACCOUNT_ACCESS_TOKEN</pre>
<p>The USER_ID is the user id of your Facebook account. Mine is apreche because my Facebook profile can be found at <a title="https://www.facebook.com/apreche" href="https://www.facebook.com/apreche">https://www.facebook.com/apreche</a>. You might not have a profile URL, in which case you can use a numerical ID instead. If your personal profile is at a URL such as https://www.facebook.com/profile.php?id=NUMBERS then use the NUMBERS as your USER_ID. Take the account access token we got from the previous step and put it in place of ACCOUNT_ACCESS_TOKEN.</p>
<p>Now visit this URL in your browser. You are going to see some slightly complicated text that is in a format known as <a title="http://www.json.org/" href="http://www.json.org/">JSON</a>. It should look something like this.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="json" style="font-family:monospace;">{
   &quot;data&quot;: [
      {
         &quot;name&quot;: &quot;PAGE_NAME&quot;,
         &quot;access_token&quot;: &quot;PAGE_ACCESS_TOKEN&quot;,
         &quot;category&quot;: &quot;Website&quot;,
         &quot;id&quot;: &quot;PAGE_ID&quot;
      },
      {
         &quot;name&quot;: &quot;APPLICATION_NAME&quot;,
         &quot;access_token&quot;: &quot;APPLICATION_ACCESS_TOKEN&quot;,
         &quot;category&quot;: &quot;Application&quot;,
         &quot;id&quot;: &quot;APPLICATION_ID&quot;
      }
   ]
}</pre></td></tr></table></div>

<p>Depending on how many different pages and applications you have on your Facebook account, you may see more than this. Regardless, you are only interested in one thing. Find the section with the PAGE_NAME of the page you want to post to and extract the PAGE_ACCESS_TOKEN from that section. This is the token we have been looking for. Save it and keep it safe.</p>
<h2>Making the Post</h2>
<p>Now that we have the page access token, we can finally do the actual status update. I will use <a title="http://curl.haxx.se/" href="http://curl.haxx.se/">curl</a> in my examples since that is language agnostic. All you really need to do is make an HTTP POST. In Python you could use <a title="http://docs.python.org/library/urllib.html" href="http://docs.python.org/library/urllib.html">urllib</a>. You could also use an appropriate Facebook library for your language, such as the <a title="https://github.com/facebook/php-sdk" href="https://github.com/facebook/php-sdk">Facebook PHP SDK</a>. It&#8217;s up to you to learn how to get this done in your programming language of choice.</p>
<p>Here is what a complete POST looks like using curl in the shell. Remember to put the PAGE_NAME and PAGE_ACCESS_TOKEN where they belong.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">$ curl <span style="color: #660033;">-F</span> <span style="color: #007800;">access_token</span>=<span style="color: #ff0000;">&quot;PAGE_ACCESS_TOKEN&quot;</span> \
<span style="color: #660033;">-F</span> <span style="color: #007800;">message</span>=<span style="color: #ff0000;">&quot;testing&quot;</span> \
<span style="color: #660033;">-F</span> <span style="color: #007800;">picture</span>=<span style="color: #ff0000;">&quot;http://i.imgur.com/2uLkT.jpg&quot;</span> \
<span style="color: #660033;">-F</span> <span style="color: #007800;">link</span>=<span style="color: #ff0000;">&quot;http://frontrowcrew.com&quot;</span> \
<span style="color: #660033;">-F</span> <span style="color: #007800;">name</span>=<span style="color: #ff0000;">&quot;Front Row Crew.com&quot;</span> \
<span style="color: #660033;">-F</span> <span style="color: #007800;">caption</span>=<span style="color: #ff0000;">&quot;FRC In the house!&quot;</span> \
<span style="color: #660033;">-F</span> <span style="color: #007800;">description</span>=<span style="color: #ff0000;">&quot;Homepage of GeekNights and other fine free entertainment.&quot;</span> \
<span style="color: #660033;">-F</span> <span style="color: #007800;">source</span>=<span style="color: #ff0000;">&quot;http://www.youtube.com/e/NKWpGJ4Xhw8?autoplay=1&quot;</span> \
https:<span style="color: #000000; font-weight: bold;">//</span>graph.facebook.com<span style="color: #000000; font-weight: bold;">/</span>PAGE_NAME<span style="color: #000000; font-weight: bold;">/</span>feed</pre></td></tr></table></div>

<p>You don&#8217;t actually have to include all of that information with every post. Just include the information that is relevant. I have simply included all of the possible information to demonstrate a complete example. Here is what the post above will look like on your Facebook page.</p>
<p style="text-align: center;"><a href="http://www.apreche.net/wp-content/uploads/2011/07/example-facebook-post.png" target="_blank"><img class="size-full wp-image-1299 aligncenter" title="Example Facebook Post" alt="Example Facebook Post" src="http://www.apreche.net/wp-content/uploads/2011/07/example-facebook-post.png" width="507" height="180" /></a></p>
<p>The avatar and the username on the posting are going to be the avatar and username of the page itself. You can&#8217;t change those from post to post.</p>
<p>The word &#8220;testing&#8221; that you see there is the message of the post. Most of the time I imagine you are going to be posting just messages without any other information.</p>
<p>After that is a separate section with the link, picture, video, and everything else. Depending on which combination of information you post, that section will work differently. You only get one of these sections per post, so depending on what you want to do, you might need to stretch it out over multiple postings. If your post only contains a message, this section won&#8217;t exist at all.</p>
<p>The link field controls the URL where the user will be sent if they click on the blue text at the top of the section. The name field controls the blue text itself. If you don&#8217;t specify a name then Facebook will visit the link and figure out a name to use. In this example the link is http://frontrowcrew.com and the name is &#8220;Front Row Crew.com&#8221;. If you know HTML you can think of it like a basic &#8220;A&#8221; tag, since that is what it is.</p>
<pre>&lt;a href="LINK_GOES_HERE"&gt;NAME_GOES_HERE&lt;/a&gt;</pre>
<p>The caption controls that light gray text directly beneath the link. The description controls the block of text that is one space beneath the caption. If you leave either of these blank then Facebook will visit the link in question and try to figure out a caption and description on its own.</p>
<p>The picture is where things start to get a little bit complicated. First of all, if you specify a link without a picture, then Facebook will actually pick an appropriate picture based on the link, just like it does with the name, caption, and description. Since it will probably pick a bad picture, I suggest you set the picture manually whenever specifying a link. The picture is just a link to any image on the web. Clicking on the picture thumbnail will take the user to the URL of the link.</p>
<p>You can actually specify a picture all on its own without any link at all. In that case clicking on the picture will take the user to see the picture in its full size. The caption, and description will be extremely barebones unless you manually specify them.</p>
<p>Source may as well be called video instead of source. It needs to be a URL directly linking to a video file, usually a flash video. I&#8217;m pretty confident other HTML5 video formats will work, but I haven&#8217;t tested them myself. Don&#8217;t make the mistake of setting the source to a video&#8217;s page like this.</p>
<pre>http://www.youtube.com/watch?v=NKWpGJ4Xhw8</pre>
<p>That won&#8217;t work. You have to set the source to be the actual video file as in the example.</p>
<pre>http://www.youtube.com/e/NKWpGJ4Xhw8?autoplay=1</pre>
<p>You are on your own on how to structure these links on other video sites besides YouTube. I think I can safely assume the vast majority of people are using YouTube.</p>
<p>If a source is set without a picture, you may get an error if Facebook can&#8217;t figure out a video thumbnail on its own. In this case, you must specify a picture to successfully make the post. The picture will be used as the thumbnail. Clicking on the picture will cause the video to play. For YouTube the player is embedded within Facebook itself. As always, your mileage may vary with other video formats and sites.</p>
<p>Now, Facebook is actually pretty smart. Let&#8217;s say you specify just a link, and that link goes directly to a YouTube page. Facebook will automatically figure out the source and picture on its own, assuming you do not manually override them.</p>
<p>Lastly, what if you specify absolutely everything as in the example above? Obviously you will have complete manual control over all of the text appearing in the post as well as the picture. Clicking on the picture will play the source video. Clicking the blue text link will always go to the specified link. In this way you can actually link to two different things. Clicking on the picture will play a video, but clicking the link can take people to your blogpost about the video or other related place on the web.</p>
<p>Also, it should be noted that there is nothing forcing the picture and video to match. You can post a thumbnail for a video that is not related to the video at all. Users might be very confused if you abuse it, but there are legitimate reasons for doing so. You might just a brand logo as a thumbnail on a video which does not include that logo.</p>
<p>One last thing. The post will always return some information formatted in JSON. If it fails there will be an error for you to read. If it success there will be an ID that is the ID of the status update you just posted. You can save and use that ID for later if you want to edit or delete the post.</p>
<h2>Conclusion</h2>
<p>Figuring this out cost me many hours. If this saves even one person from that struggle, then it was worth it.</p>
<p>I hope this can also serve as an example to other people who write technical tutorials or howtos. You can&#8217;t just skip over details. You need to include every step and explain the what, why, and how of all those steps. Otherwise readers have to go to ten different sites to piece together the complete picture like I did. Even worse, users might blindly copy and paste without understanding what they are doing.</p>
<p>And of course, I hope this shows just how much of a pain OAuth can be when it is used unnecessarily. With my suggestion of every account also being an application, many of the OAuth steps would be eliminated without sacrificing any security or privacy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/tutorial-programatically-post-a-status-update-to-your-facebook-page/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>To OAuth or Not to OAuth</title>
		<link>http://www.apreche.net/to-oauth-or-not-to-oauth/</link>
		<comments>http://www.apreche.net/to-oauth-or-not-to-oauth/#comments</comments>
		<pubDate>Sat, 23 Jul 2011 23:22:42 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1269</guid>
		<description><![CDATA[You&#8217;re feeling some pains, so you go see a doctor. The doctor sends you to have some tests done at a lab on the other side of town. The results come in a week later and you have to get &#8230; <a href="http://www.apreche.net/to-oauth-or-not-to-oauth/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>You&#8217;re feeling some pains, so you go see a doctor. The doctor sends you to have some tests done at a lab on the other side of town. The results come in a week later and you have to get those results into your doctor&#8217;s hands. You could just go back across town and get them, but that&#8217;s a pain. It would be much easier if your doctor could get the results directly from the lab. It would be even better if they could be transferred digitally.</p>
<p>But now we run into problems of security. What if someone else calls the lab impersonating your doctor and gets your test results? What if you change doctors and the lab releases the test results to your old doctor against your wishes? What if the lab is full of jerks and they send all sorts of crap to your doctor in your name. We have this exact same problem on the Internet, and that is why <a title="OAuth" href="https://secure.wikimedia.org/wikipedia/en/wiki/OAuth">OAuth</a> was created.<span id="more-1269"></span></p>
<p>For decades the most popular means of authentication on computers has been usernames and password combinations. You want to prove to some system that you are a certain person, so you enter in a secret piece of information that only you know to prove you are you. Now that you have identified yourself the system will allow you to engage in activities permitted to your account.</p>
<p>Now let&#8217;s say you have a newsletter system, and you want it to send out emails on your behalf. Even to this day a very popular way of doing this is to give the newsletter system the username and password to your email account. The newsletter system will authenticate on your behalf, so your email server will think that the newsletter system is you. That&#8217;s what authentication is all about. As far as your email server is concerned the newsletter system <em>is you</em>, and has permission to do everything you do, including changing your password or deleting your account.</p>
<p>It&#8217;s obvious that this is a problem. Even though that goes against everything you&#8217;ve ever learned about security and passwords, people still do things this way. You should never tell your password to any other person ever, not even your closest and most trusted people like spouses. You definitely shouldn&#8217;t tell it to other computer systems. You should only ever send a password to the system for which it is intended. Your email password is for you, your email server, and that&#8217;s it.</p>
<p>Well, I made this fun game on the web, and my users want to tweet out their high scores. I could just suggest they do it with copy/paste, but that&#8217;s like driving back and forth across town to get the test results. Instead, I want my game to do the tweeting on behalf of the users for the greatest efficiency. Now I could, and many systems did, just ask for the users to give me their twitter usernames and passwords. It is possible I could be honest and not abuse that, but do you trust me? Even if I was an entirely client-side application, and your password is being sent directly to Twitter, this game is not officially endorsed by Twitter. How do you know I&#8217;m not secretly sending your password to my own servers or doing something else shady?</p>
<p>Thankfully we have solved this problem, and the solution is OAuth. OAuth is slightly complicated, but it gets the job done. Let me explain it as simply as I can using our high score game tweet example. We&#8217;ll call the game shootyguy.</p>
<p>You have a Twitter account, and I want you to let shootyguy send tweets on that account. First shootyguy gets its own special twitter application account. That account has an ID and a secret, which is basically the same as a username and password. Now shootyguy can authenticate with Twitter and prove that it is indeed shootyguy.</p>
<p>When you get a high score for the first time it will give you a link saying &#8220;click here to let me send tweets for you!&#8221; That link is a link to Twitter. It contains shootyguy&#8217;s ID number and a list of the things shootyguy wants you to let it do. In this case the game is only asking permission to send tweets, but it could also ask permission to edit your avatar, change your profile, etc.</p>
<p>You click on this link and you are sent to Twitter itself. It&#8217;s safe to give your Twitter password to Twitter, obviously. You do so, and Twitter asks you, &#8220;Hey, do you want to let shootyguy do the following things with your account?&#8221; If you say no, nothing will happen. If you say yes, then Twitter will remember that shootyguy has permission to send tweets for you. It will also send shootyguy a special secret password that it can use to act on your behalf. If shootyguy is a popular game, it&#8217;s going to have to remember those secret passwords for every user who has tweeting enabled. As long as the game holds onto these secrets, and you don&#8217;t take permission away from it, it won&#8217;t have to ask permission again. This painful user interface problem of jumping back and forth between web sites only has to happen once ever.</p>
<p>This is what is called authorization. You see, both you and shootyguy authenticate with Twitter to prove you are who you say you are. You are authorized to do whatever you want with your own account. Shootyguy is authorized to send tweets, but nothing else, on a whole bunch of accounts that have granted it permission. Up until relatively recently we didn&#8217;t have authorization, just authentication. Now that we have it, it&#8217;s easy to see why it is so incredibly important.</p>
<p>Perhaps the most important feature of authorization is the ability to deauthorize. Imagine if shootyguy got hacked like the PSN and it had a database full of Twitter passwords. That would be extremely bad. You would have to change your password before hackers started using it. If they had used OAuth, you could just remove authorization for the compromised application, and your account would be perfectly safe. Worst case the hacker starts doing the few things you authorized them to do before you turn them off.</p>
<p>I think I have made it very clear that in cases where you want to give a third party access to one of your accounts, OAuth, or a similar authorization system, is an absolute necessity. Anything less is grossly negligent.</p>
<p>Given that, what is up with the title of this blog post? Shouldn&#8217;t it be &#8220;Always OAuth&#8221;? Well, that seems to be the opinion of many sites out there such as Twitter and Facebook who are forcing OAuth as the only way to interact with their APIs. I can see why they do this. OAuth is more complex to implement, so developers would keep taking the easy way out by collecting passwords if they were not forced to use OAuth. It&#8217;s also next to impossible to educate users on not giving out their passwords.</p>
<p>Yet, there are still those rare occasions when OAuth becomes a huge pain in the ass for no benefit whatsoever. Let&#8217;s turn the tables around a little bit. Let&#8217;s say that we make an official shootyguy twitter account. We want to automatically tweet on that account whenever a player beats the game at shootyguy.com. How does that work?</p>
<p>In this case, we don&#8217;t need to ask the player for authorization. We aren&#8217;t using the player&#8217;s Twitter account. Shootyguy is using its own account. There&#8217;s no benefit to using OAuth in this case. It would just be easier for shootyguy to authenticate with its own username and password, and have full authorization to tweet with its own account.</p>
<p>The problem is that shootyguy is a program, not a person. It can&#8217;t just visit twitter.com and send a tweet. It has to use the API to tweet programmaticaly. But the API forces you to use OAuth no matter what. Since it is a program, and not a person, how can it click the &#8220;Allow&#8221; button in the browser? It can&#8217;t. What you have to do is manually do the OAuth in a browser and collect and save all the secret keys along the way. Then you put all the secret keys on the shootyguy.com server so it can send tweets.</p>
<p>Is it really that hard? No, there are many things that are more difficult, but it&#8217;s still a pain. In a way it makes sense. The shootyguy account is giving permission to the shootyguy.com application to tweet on its behalf. But Twitter is actually pretty simple as far as OAuth goes. If you want to see frustration, try it with Facebook.</p>
<p>Pretend that instead of posting to a shootyguy twitter account, we want to post onto the wall of the official shootyguy Facebook page. Well, a Facebook page isn&#8217;t a Facebook account, or is it? And a Facebook account isn&#8217;t a Facebook app. I&#8217;m going to write a tutorial on every step involved in doing this, but here&#8217;s the TL;DR version. You have to create a facebook account, a page, and an application. You have to authorize the account to post onto the page. Then you have to authorize the application to have a bunch of permissions on the account. Then the application has to use its secret keys on the account to get yet another secret key it can use to access the page.</p>
<p>Again, this is actually a great system when you are using it for what OAuth was designed for. If you want to give the game permission to post on your personal Facebook wall, this is fantastic. For the game to post on its own Facebook wall this is awful.</p>
<p>Of course, my complaining isn&#8217;t for naught. I actually have a solution that doesn&#8217;t require changing OAuth itself in any way. The solution is actually quite simple, and it actually opens the door to more features for users that have been unexplored.</p>
<p>I won&#8217;t hold back, the answer is to make every account also an application that has full authorization of itself. Why are applications and accounts separate entities? Why do I have to make my own Facebook application and connect it to my account? If my account were also an application, it would only need authorization to do things with other accounts, but not as itself. I shouldn&#8217;t have to pretend to be an authorized third party application to post on my own personal Facebook wall through the API.</p>
<p>One side benefit of this is that every user account can be authorized to perform actions on other user accounts. That can be dangerous if people give too much authorization away, but I think it will be very clear to people what is going on. &#8220;Do you want to give your friend joeyjoejoe1337 the ability to edit your profile? Yes or No?&#8221; It&#8217;s not a question too many people are going to get wrong.</p>
<p>While you may not immediately realize it, there are many cases where people will want to say yes. A parent can give their children their own personal private accounts, but can then authorize their own accounts to have a certain amount of access. You could authorize your trusted friends to handle your accounts in case of emergency without giving anyone your passwords. You could have a company account and give many people access to it without sharing a password around the office. You could then easily add and remove authorization as employees come and go. There are many duct tape third party systems that add this functionality for businesses that could be done away with completely if my idea were implemented.</p>
<p>I hope from reading this that you have a good conceptual understanding of the difference between authentication and authorization. I also hope you understand what OAuth is, why we have it, and why it is so great. And though I know it won&#8217;t change anything, I just wanted to complain about the unnecessary complexity that can make OAuth sucky under certain circumstances. If you are building an application, make sure you use it appropriately, and please try out my idea of every account being an application. And remember, never ever give your password for anything to absolutely anyone at any time under any circumstance. It is never necessary. No, not even in that circumstance you just suggested.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/to-oauth-or-not-to-oauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>You Don&#8217;t Impress Me. Try These Hacks Instead.</title>
		<link>http://www.apreche.net/you-dont-impress-me-try-these-hacks-instead/</link>
		<comments>http://www.apreche.net/you-dont-impress-me-try-these-hacks-instead/#comments</comments>
		<pubDate>Sat, 18 Jun 2011 04:09:11 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1261</guid>
		<description><![CDATA[Recently there have been a lot of computer security attacks. It&#8217;s actually hard to say if they are more frequent now than they have been in the past. What is certain is that they are being publicized more now than &#8230; <a href="http://www.apreche.net/you-dont-impress-me-try-these-hacks-instead/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Recently there have been a lot of computer security attacks. It&#8217;s actually hard to say if they are more frequent now than they have been in the past. What is certain is that they are being publicized more now than before. Even so, the majority of these attacks are lame. I may agree or disagree with the motivations behind some of them, but they are almost all just pathetic. I am disappointed.<span id="more-1261"></span></p>
<p>Firstly, these attacks are not really all that effective. Defacing web sites? Releasing customer data? That doesn&#8217;t make any difference in the grand scheme. Do you remember viruses like <a title="Ogre Virus" href="http://www.research.ibm.com/antivirus/SciPapers/Chess/PCCOMVIR/note209.html">the ogre</a>? It erased all drives in a computer. When was the last time someone wrote a virus that  actually did serious damage like that? I&#8217;m not aware of any  in recent memory.</p>
<p>Why don&#8217;t we see such harmful attacks anymore? Is it because that sort of attack doesn&#8217;t serve the motivations of the hackers? Is it because our modern systems are properly hardened against these kinds of attacks? Are these attacks happening and not being publicized?</p>
<p>Whatever the reason is, it is both disappointing and encouraging. You see, I can respect this sort of attack in the way that I can respect someone like Mike Tyson. His boxing is a sight to behold, but I have no desire to behold a man having his ear bitten off. You can impress me by writing a virus that turns off CPU fans and forces people to buy new PCs, but I don&#8217;t actually want to see that to happen. That makes the world a worse place by wasting a bunch of valuable resources for no benefit.</p>
<p>Secondly, these attacks lack technological sophistication. SQL injection and DDoS against soft targets? Please. These techniques aren&#8217;t demonstrative of deep technological knowledge. Regardless of my feelings on the motivations or target of an attack, as a technology professional I have a hard time respecting such easy hacks.</p>
<p>Imagine someone who burglarizes an old grandma who left the door unlocked. Even if it was a mean old grandma who needed to be taught a lesson about security, that thief isn&#8217;t going to get love from anyone. Because the burglary was so easy, the perpetrator is easily branded as a coward and lowlife scum.</p>
<p>Meanwhile, there are two other kinds of thieves who do get love and respect that makes up for their evil ways. The first is the professional thief or con-man. Their talents are so great that we can romanticize their stories and root for them. Despite acting immorally, their biographies become hit movies. The other kind is the Robin Hood who commits a crime for a good purpose. They do something that is illegal, but is not viewed as wrong given the circumstances.</p>
<p>What I want to see happen are some attacks that are both technologically difficult and have effects that benefit the world in some great way. If you are willing to so blatantly ignore the law, unlike myself, then cut it out with the lame hacks. Do something big and serious that in and of itself will have a huge positive effect for all people on the planet. Don&#8217;t be that guy who robs a convenience store at gunpoint. Instead, strive to be like <a title="Lupin III" href="https://secure.wikimedia.org/wikipedia/en/wiki/Ars%C3%A8ne_Lupin_III">Lupin III</a> or <a title="Frank Abagnale" href="https://secure.wikimedia.org/wikipedia/en/wiki/Frank_Abagnale">Frank Abagnale</a>.</p>
<p>Since things like this haven&#8217;t really been done before, I think I have to give some examples. Here are my top ten ideas of possible hacks that would have a huge positive benefit on society. The perpetrators of these attacks would definitely earn a great deal of respect to go with their time in prison. Post your own ideas in the comments!</p>
<ol>
<li>Hack stores like iTunes or Steam to give everyone free games, movies, music, etc. Remove region locking on services like Hulu and Spotify. Allow art and culture to be spread around the world for free.</li>
<li>Release the source code to important programs like Adobe Creative Suite, Microsoft Windows, iOS, the Google Search algorithm, etc.</li>
<li>Take control of ISPs to remove filtering, bandwidth limiting, wire tapping, and other nefarious systems.</li>
<li>Hack into the systems that host and sell academic journal articles, and get the full text of all the articles onto the net somewhere for free.</li>
<li>Hack into the world&#8217;s financial systems and bring down all the evil investment banks like JP Morgan, Goldman Sachs, etc.</li>
<li>Hack into government and corporate back office systems to expose corruption around the world. I&#8217;m sure there are plenty of Enrons waiting to be discovered.</li>
<li>Completely disable industrial facilities that are hazardous to the environment. Even if they come back online, a few days without something like coal burning makes a big difference even at the expense of a power outage.</li>
<li>Completely bring down the great firewall of China or other Internet censorship systems.</li>
<li>Attack the television satellites and turn off almost every TV in the world for a significant time period. At the very least replace Fox News with Al-Jazeera English.</li>
<li>Disable the nuclear arsenals of every country that has them. Let the power plants stay, just disable all the missiles.</li>
</ol>
<p>I think you get the idea now. LulzSec and others have been thinking too far inside the box. The lack of imagination and lack of technological skill is why nothing like the attacks I&#8217;ve describe has happened, or will happen anytime soon. If anything like the items on my list even comes close to happening, I will be more impressed than I have been in my entire life. As of right now, I&#8217;m still yawning.</p>
<p>I fully expect to wake up tomorrow to see that my computers will not boot, and they just display laughing skulls all over the screen. I&#8217;d be mad that I would have to fix all my computers, but a little bit happy that that can still happen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/you-dont-impress-me-try-these-hacks-instead/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Keep your California out of my New York</title>
		<link>http://www.apreche.net/keep-your-california-out-of-my-new-york/</link>
		<comments>http://www.apreche.net/keep-your-california-out-of-my-new-york/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 23:33:33 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1257</guid>
		<description><![CDATA[More and more the entrepreneurial community has integrated itself into the technology community. You have to commend them on what an excellent job they have done. At this point startup news and technology news are basically synonymous. At least half &#8230; <a href="http://www.apreche.net/keep-your-california-out-of-my-new-york/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>More and more the entrepreneurial community has integrated itself into the technology community. You have to commend them on what an excellent job they have done. At this point startup news and technology news are basically synonymous. At least half of articles posted on tech sites are actually about business and have little at all to do with technology. I&#8217;ve mostly just observed and lightly complained about them, but now they are trying to attack my home turf. They are attacking New York City.<span id="more-1257"></span></p>
<p>Just about every day I read about some article about turning New York City into Silicon Valley 2. What bothers me is they take it for granted that this is a thing that is a good idea, and move right along to discussing how it can be done. It&#8217;s obvious why the startup people want to do this. There are a lot of people and, more importantly, a lot of dollars in NYC. It&#8217;s the most important city in the world. Yet, there are few technology-centric businesses based here. To these people the city is a huge untapped mine filled with gold.</p>
<p>The thing is, the location of technology companies doesn&#8217;t really matter that much does it? If I were starting a tech company I would probably pick Kansas City once Google brings the fiber there. The Netherlands is also a good choice, and has the fiber right now. The only real reason they come to NY is because they need more developers. The valley is tapped.</p>
<p>If they have marketed these entrepreneurial ideas so well, why are they having a hard time getting these developers? Why can&#8217;t they replicate the valley in New York? What is giving them all this trouble? I&#8217;ll make a general trollish statement and say that New Yorkers aren&#8217;t morons like those Californians are. Less trollish statement, New Yorkers aren&#8217;t as naive as Californians.</p>
<p>You see anyone who has a silicon valley attitude already probably moved there, or wants to move there. If someone stayed in New York it&#8217;s because they have a New York attitude. We aren&#8217;t the kind to work all night eating only instant noodles in exchange for a miniscule chance of getting rich and making some venture capitalist much richer. We have something here called rent, and it&#8217;s really expensive. We also like to eat good food, which is also very expensive. If you want us to work for you you have to pay us in cash, and lots of it. Venture capitalists don&#8217;t like that. They want kids right out of college who will work for peanuts because they don&#8217;t know any better.</p>
<p>Also, while New York lacks technology companies, it doesn&#8217;t lack technologists. Every desk has a computer on it. There are thousands of technologists in this city, many of them among the best in the world. The thing is, we all work for companies that do something else besides technology. Many work for financials that make money by having money to begin with. Some work for insurance companies, media companies, advertising firms, or *gasp* companies that actually have a product to sell. In other words, we work for businesses that actually make a real profit with a real sustainable business model that hasn&#8217;t been made obsolete like Hollywood has.</p>
<p>All these venture funded startups, how many make real profits? LinkedIn just had a huge IPO, how much profit do they actually make? Apparently  the company is valued at <a title="LinkedIn Valued at 521 times its profits" href="http://blogs.wsj.com/deals/2011/05/19/linkedin-now-valued-at-521-times-profits/">521 times its profits</a>. I don&#8217;t know how math works in CA, but in NY we know how to use a calculator. That doesn&#8217;t add up. If we&#8217;re going to work somewhere and get paid, it better be someplace that actually makes money. If you promise me the salary I demand, you better damn well not bounce that check.</p>
<p>These people are treating investment dollars like they&#8217;re revenues. In NY people are still living in the real world. We&#8217;ll get excited about real things, like sales figures going way up. If some morons decide to invest a huge sum in a company that isn&#8217;t turning a profit, that&#8217;s not something to cheer about. It&#8217;s something to be very worried about. If I see the champagne opening, my first instinct is to run.</p>
<p>I also have a suspicion that the weather makes a big difference. New York has nice weather, but the winter is cold and snowy. That has a huge psychological effect on people. Because we are often grumpy, we want to escape. If you make a New Yorker rich, you know what they&#8217;ll do? They&#8217;ll buy a luxury apartment, a house in the Hamptons, and a tropical beach house. Then they&#8217;ll retire immediately never to be seen again. Make a valley entrepreneur rich, and they&#8217;ll show up to work the next day like nothing happened. The weather is so nice, they are happy with their late nights and ramen dinners. They don&#8217;t want to escape, they are happy to work forever.</p>
<p>If you&#8217;re one of those people trying to push your silicon valley mentalities in New York, let me be the first to tell you to literally get out of town. You&#8217;re not wanted here. If anything, I think you guys should take a little New York back home with you. When you have real money and are ready to pay my rent, then give me a call. Until then, save your cash for plane tickets.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/keep-your-california-out-of-my-new-york/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Game Developers &#8211; Stop Failing at Online Multiplayer</title>
		<link>http://www.apreche.net/game-developers-stop-failing-at-online-multiplayer/</link>
		<comments>http://www.apreche.net/game-developers-stop-failing-at-online-multiplayer/#comments</comments>
		<pubDate>Sat, 28 May 2011 14:40:29 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1250</guid>
		<description><![CDATA[Independent video games are all the rage lately. Minecraft and Angry Birds are the premiere examples of how games developed outside of the big commercial industry can become huge successes. This is mostly because of platforms like Steam and other &#8230; <a href="http://www.apreche.net/game-developers-stop-failing-at-online-multiplayer/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Independent video games are all the rage lately. <a title="Minecraft" href="http://www.minecraft.net/">Minecraft</a> and <a title="Angry Birds" href="http://chrome.angrybirds.com/">Angry Birds </a>are  the premiere examples of how games developed outside of the big  commercial industry can become huge successes. This is mostly because of  platforms like <a title="Steam" href="http://store.steampowered.com/">Steam</a> and other digital stores allowing these games to get vast exposure.  This is great because after years of genre cookie cutters we finally  have a new fountain of ludic innovation in the video game world.</p>
<p>Despite the greatness in the indie video game scene, there is also a  great deal of fail. Because indie developers lack the resources of giant  corporations like <a title="Nintendo" href="http://www.nintendo.com/countryselector">Nintendo</a> or <a title="Electronic Arts" href="http://www.ea.com/">Electronic Arts</a>,  there are certain flaws in their games that we have to accept. The  controls won&#8217;t be as polished and smooth. There might be graphical  glitches on certain video cards. The game might crash under weird  circumstances. Without the money or time for thorough testing, this is  just a reality of life we must accept. I forgive the indie games for  these kinds of flaws.</p>
<p>That being said, there is one area in which failure is absolutely not  acceptable. That area is online multiplayer. It seems that just about  every week a cool new multiplayer game comes out on Steam, but the  networking is a complete disaster. This is absolutely unacceptable. If  it&#8217;s primarily a single player game with a small online component, then  it&#8217;s no big deal if that part doesn&#8217;t work. However, if it&#8217;s primarily  an online game then the game may as well not exist if the networking is  busted. <img title="More..." src="http://comments.apreche.net/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" /></p>
<p><span id="more-1250"></span></p>
<p>As a programmer I know full well how difficult it is to write netcode  that works. There are so many factors to balance including latency,  synchronization, cheating, firewalls, etc. It&#8217;s no doubt a huge pain to  write good net code. To those that have succeeded in this task, I salute  you.</p>
<p>Even worse, writing netcode is a distraction from making your game. A  game developer wants to make their game as good as possible. In a  competitive online multiplayer game that means working on things like  balance, controls, user interface, level design, and adding more modes  of play. Every minute spent working on netcode is a minute a developer  is distracted from the game itself. It&#8217;s no wonder that developers don&#8217;t  spend much time on it.</p>
<p>That being said, if your game is primarily an online multiplayer  game, it may as well not even exist if the netcode doesn&#8217;t work. I  acknowledge that it is difficult code to get right, and that it  distracts from the task of actually making the game. I just don&#8217;t accept  those as valid excuses. Networking is hard, not impossible.</p>
<p>In 1996 Id software released <a title="QuakeWorld" href="https://secure.wikimedia.org/wikipedia/en/wiki/QuakeWorld">QuakeWorld</a>. The original <a title="Quake" href="https://secure.wikimedia.org/wikipedia/en/wiki/Quake_%28video_game%29">Quake</a> had netcode that was only suited for LAN play. QuakeWorld fixed it so  that Quake could be played beautifully over the Internet. <a title="Tribes 2" href="https://secure.wikimedia.org/wikipedia/en/wiki/Tribes_2">Tribes 2</a> was released in 2001. The netcode was so amazing that the game was  playable with a 56k modem. We are living in the year 2011. No matter how  hard the netcode problem is, it&#8217;s been a solved problem for fifteen  years. I&#8217;m sorry. There is absolutely no excuse for getting it wrong.</p>
<p>One reason people fail is because they try to do something other than  the classic dedicated server model. In my opinion, this is the way all  non-MMO games should do online play. It&#8217;s a design that works  beautifully for over a hundred thousand <a title="Counter-Strike" href="http://store.steampowered.com/css">Counter-Strike</a> players every second of every day. I&#8217;m all for trying new things. <a title="Rotary Engine" href="https://secure.wikimedia.org/wikipedia/en/wiki/Wankel_engine">Rotary engines</a> are pretty cool because they actually work. If you want to try to make a  new kind of network engine, that&#8217;s great, but it had better work.</p>
<p>Not following this advice is how we get games like <a title="Frozen Synapse" href="http://www.frozensynapse.com/">Frozen Synapse</a> trying to use centralized servers that they can&#8217;t keep available. It&#8217;s a  turn-based game, and they can&#8217;t even keep the server up. We also get  games like <a title="Ace of Spades" href="http://ace-spades.com/">Ace of Spades</a> which wants to launch the game from in-browser links instead of typing  IP addresses into the game itself. Most times when you try to play you  just get a connection error. If these developers had done things the old  fashioned way, they might be in better shape.</p>
<p>Another mistake developers make is they don&#8217;t build the networking in  from the ground up. Having online play affects the overall design of  your game in many ways. If you don&#8217;t code your game with networking in  mind from the very beginning, it will be enormously difficult to  properly add it later on.</p>
<p>Minecraft has this problem, and that&#8217;s why so many people keep making all sorts of <a title="Bukkit" href="http://bukkit.org/">server mods</a> for it. Even with the mods I consider the Minecraft multiplayer too  awful to be even worth playing. Notch has the money now. If he wants  multiplayer to not suck, he should build a new Minecraft that is  designed for networking from the start. They can call it Multicraft.</p>
<p><a title="Civilization V" href="http://www.civilization5.com/">Civilization V</a> is a massive failure in this regard. Not only are their lag and  connection issues, but the actual game mechanics actually don&#8217;t hold up  in multiplayer. The simultaneous turns give a <a title="Civilization V Simultaneous Combat" href="http://gaming.stackexchange.com/questions/9680/how-does-simultaneous-combat-work-in-civilization-5">huge advantage to the first mover</a> in combat. When <a title="Civilization IV" href="http://www.2kgames.com/civ4/home.htm">Civ IV</a> came out, people stopped playing <a title="Civilization III" href="http://www.civ3.com/">Civ III</a>.  The fact that many people are still playing Civ IV after Civ V has been  out for months shows you they really messed something up.</p>
<p><a title="Magicka" href="http://www.magickagame.com/">Magicka</a> is a game with a ton of network problems. Even after tons of patches, the game still gets out of sync. <a title="Diablo II" href="http://us.blizzard.com/en-us/games/d2/">Diablo II</a> was perfect in 2001, so why is Magicka flawed? The <a title="Torchlight" href="http://www.torchlightgame.com/">Torchlight</a> guys have the right idea. They have no networking whatsoever in  Torchlight. If you can&#8217;t do it right, don&#8217;t do it at all. They are  making <a title="Torchlight II" href="http://www.torchlight2game.com/">Torchlight II</a> with networking in mind from the start. I have high hopes for them doing a good job.</p>
<p><a title="Natural Selection" href="http://www.unknownworlds.com/ns/">Natural Selection</a> is my second favorite FPS of all time after Tribes 2. It&#8217;s a <a title="Half-Life" href="https://secure.wikimedia.org/wikipedia/en/wiki/Half-Life_%28video_game%29">Half-Life</a> mod, so the networking just works perfectly. I was very excited for <a title="Natural Selection 2" href="http://www.naturalselection2.com/">Natural Selection 2</a>,  and I pre-ordered it immediately. The developers started out on the  Source engine, but abandoned it to write their own. While their engine  is very impressive, they have failed at networking. Their experience  comes from making mods, so they had no experience with networking.  Perfect netcode was provided for them by the underlying engine. Natural  Selection 2 is still in beta, but the networking is awful. There is  insane lag. It gets better with every patch, but it is still nowhere  near satisfactory. At least we&#8217;ll always have NS1.</p>
<p>You might argue that some of these games are commercially successful  despite their sub-par networking. That is true, but they are very lucky.  <a title="Introversion" href="http://www.introversion.co.uk/">Introversion </a>software released a great RTS called <a title="Multiwinia" href="http://www.introversion.co.uk/multiwinia/">Multiwinia</a>.  When it was first released many people could not connect to any servers  due to network errors. I don&#8217;t know if they eventually fixed it because  I stopped playing. The broken online play prevented a community from  forming around the game, and the game died. Compare that to <a title="Defcon" href="http://www.introversion.co.uk/defcon/">Defcon</a>, another Introversion game that has working online play, which still has a community to this day.</p>
<p>I&#8217;m sure everyone is also familiar with the Nintendo way of failing  at online multiplayer. Friend codes and other weird systems create a  huge barrier to online play, even if the netcode works. <a title="Borderlands" href="http://www.borderlandsthegame.com/age_gate.html">Borderlands</a> has fine netcode, but reliance on <a title="GameSpy" href="http://www.gamespy.com/">GameSpy</a> accounts makes it annoying as hell to get it running. Steam and <a title="XBox Live" href="http://www.xbox.com/en-US/live">XBox Live</a> are both perfect. Every single game should integrate as much as  possible with one or both of those systems. Why would you intentionally  create a barrier to entry for your game?</p>
<p>Networking is hard, so it is obvious why so many game developers fail  at it. It&#8217;s just incredibly frustrating for us as gamers to spend money  on a multiplayer game that has broken online play, where there is  really no excuse. Almost every game should use the standard model of  dedicated servers integrated with XBox Live and/or Steam as fully as  possible. It&#8217;s bad enough that so many games with big potential die out  from lack of interest, it&#8217;s an even greater shame if it&#8217;s due to  technological failure.</p>
<p>Right now I&#8217;m at a point where I buy all kinds of cool indie games  only to be disappointed when the networking doesn&#8217;t function. I&#8217;m at the  point where I&#8217;m not even going to buy games now until I have  confirmation that they work. With more technological failures more  people might take on this attitude, and it could be a serious blow to  indie game developers, and thus a serious blow to video game innovation.  Nobody wants to see that, so just make the networking work. There&#8217;s no  valid excuse.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/game-developers-stop-failing-at-online-multiplayer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Why Not a Little Open?</title>
		<link>http://www.apreche.net/why-not-a-little-open/</link>
		<comments>http://www.apreche.net/why-not-a-little-open/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 22:30:19 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1243</guid>
		<description><![CDATA[If you look around at the world of hardware, there is one thing that is immediately obvious. The open hardware is shit compared to the closed hardware. In terms of industrial design, battery life, price, and just about every category &#8230; <a href="http://www.apreche.net/why-not-a-little-open/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you look around at the world of hardware, there is one thing that is immediately obvious. The open hardware is shit compared to the closed hardware. In terms of industrial design, battery life, price, and just about every category other than openness, the closed devices are superior. The thing is, it doesn&#8217;t have to be this way, and the electronics manufacturers would actually stand to make much more money if they bucked the trend.<span id="more-1243"></span></p>
<p>Take for example the <a title="Nintendo DS" href="http://www.nintendo.com/ds">Nintendo DS</a> vs. something like the <a href="http://www.openpandora.org/">Pandora</a>. The Pandora is really no comparison. Just looking at it makes me shudder it&#8217;s so hideous. There&#8217;s little incentive to actually develop anything for it since nobody owns one. Hooray, you made a game for the Pandora that nobody will ever play.</p>
<p>Meanwhile, the Nintendo DS is a closed system. Nintendo will only give you a dev kit if they approve you, and you pay them money. Then you can only release your game if they approve of that. This hasn&#8217;t stopped people from reverse engineering it and homebrewing the heck out of it. There is more homebrew action going on the DS than on even the most popular open systems out there. The incentives of developing for such a widely used well designed system make with worth the hassle of hacking and reverse engineering it.</p>
<p>The same is true for almost all consumer electronics. We have a bunch of open devices that suck and don&#8217;t really work, and we have awesome closed devices that we have a hard time pushing beyond their limitations. What would happen if one of the companies making closed devices would just cave and open it up?</p>
<p>Actually, this has happened. Do you remember the Linksys WRT54G router? I don&#8217;t have sales figures, but it&#8217;s obviously one of, if not the, best selling routers of all time. Because of the GPL, Cisco was forced to open the source code of the firmware for early versions of the router. The result is that a huge community sprung up of people buying this router and flashing it with firmware that added a ton more features. This obviously helped their sales by a ton, so why did they change the software in later versions and keep their future routers closed? If they had kept their routers open, Netgear, D-Link, and everyone else would have no chance of competing unless they opened up as well.</p>
<p>Now, depending on the device, going completely open can pose problems. Sometimes it can allow software piracy, like with the iPhone or DS. Sometimes it can allow media piracy, such as with an open source Blu-Ray player. But even in those cases, an official dev kit that anyone can buy will not help piracy that much.</p>
<p>Even with completely closed Blu-Ray players, the whole system is already cracked wide open. Pirates are pirating, and will continue to pirate. Little to nothing can be done to change the rate of piracy. Yet, imagine if Sony made one particular model of Blu-Ray player that was open. Without marketing it heavily, they just had a page on their site with documentation and development tools for the player. Maybe they even discreetly sell a dev kit for a token fee. That will almost immediately become the #1 Blu-Ray player, and no other will be able compete with it.</p>
<p>Imagine if Nintendo discreetly sold official DS flash cartridges with a development kit. They would make a ton of money since all those dollars spent on R4 cards would be in Nintendo&#8217;s wallet. Piracy of DS games is rampant and unstoppable anyway, this would at least give more money to Nintendo instead of the people who make the R4.</p>
<p>Of course, this will never happen. These big old companies are set in their ways, and there is pretty much zero chance they will be smart enough to do something like this. They are too stubborn and old fashioned.</p>
<p>That doesn&#8217;t mean it can&#8217;t happen. I&#8217;m calling out all the people who make open hardware to change their ways. Instead of making something like Pandora, make a product with a consumer focus. If you design for developers, you&#8217;ll only get developers buying it. Be like a real company and focus completely on consumer sales. Just while you&#8217;re at it, make the device open and make development tools available or for sale. Don&#8217;t heavily promote the openness, promote the device itself. By keeping the openness quiet you won&#8217;t scare anyone away, and you&#8217;ll grow a sleeper hit from the underground. Think of it as Linksys router on purpose.</p>
<p>Imagine yourself right now trying to buy something like, oh, a television. There are so many to choose from in different sizes with different specs. But one feature that no television has is openness. Imagine if there was just one model of television that had a dev kit available on some page of the manufacturer&#8217;s web site. They didn&#8217;t promote it or draw attention to it, but they had it there. Would that not immediately become the most popular television? Of course it would. It would be the obvious choice of almost every nerd. After the nerds got done with it, it would become the obvious choice of non-nerds as well.</p>
<p>If you are a consumer electronics manufacturer, please make your stuff open. It&#8217;s in the best interest of your company and your customers. Throw away your old ways of thinking. Just do it. Just try it on one model. If it doesn&#8217;t work, cancel it. At least try. What&#8217;s the worst that can happen? It sells the same as it would have sold if it were closed? That&#8217;s not likely.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/why-not-a-little-open/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Play Doom</title>
		<link>http://www.apreche.net/how-to-play-doom/</link>
		<comments>http://www.apreche.net/how-to-play-doom/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 23:28:03 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1239</guid>
		<description><![CDATA[Just yesterday I read this fascinating piece by Stephen Totilo of Kotaku entitled The First Time I Played Doom Was Yesterday.  It&#8217;s really crazy that in this world, even a video game journalist with an incredibly long tenure could have &#8230; <a href="http://www.apreche.net/how-to-play-doom/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Just yesterday I read this fascinating piece by Stephen Totilo of Kotaku entitled <a href="http://kotaku.com/5608100/the-first-time-i-played-doom-was-yesterday">The First Time I Played Doom Was Yesterday</a>.  It&#8217;s really crazy that in this world, even a video game journalist with an incredibly long tenure could have completely missed playing Doom, one of the most important video games in history.</p>
<p>What fascinated me even more was that he had trouble actually getting the game to work. Even if this day and age when people can run Doom on everything from iPods, pocket watches, to microwave ovens, it&#8217;s very strange that someone would have trouble running it on desktop x86 PC. Because I think it is so important that every person, and especially every gamer, should at least have experience with this game, I present to you a tutorial on how to play Doom.</p>
<p>The first step is acquiring the game. This isn&#8217;t really as obvious as you might think. You see, the Doom engine has been open source for a very long time. The only part that is not free and open source is the game data itself. The maps, the art, the textures, all those things are still commercially owned by Id software, and you must pay money to acquire them legally.</p>
<p>The Doom engine stores all of those things in WAD files. An entire game for the Doom engine is stored in a single WAD file. You can, of course, acquire them illegally. If you don&#8217;t pay money, but want to stay legal, you can only acquire the Doom demo version WAD files. Personally I suggest you go on Steam and purchase the id super pack. It&#8217;s a great deal that will also give you Quake, Quake 2, Commander Keen, and many other games which are required playing. Make sure after you purchase the games that you install them in Steam to get the files downloaded to your machine. It should take a matter of seconds on a fast connection.</p>
<p>Now, if you are running Windows, you could attempt to play these games directly in Steam. This will launch the original Doom engine using DOSBox. This might work for you (it does for me), or it might not (it didn&#8217;t for Totilo). Even if it works, it is not a great experience. This engine was designed for DOS, and it shows its age on modern machines. It will run at a really crappy resolution, and it has limited options to make things any easier on you. Stick with it if you are a purist, but I&#8217;m betting you aren&#8217;t.</p>
<p>I do suggest that if it works for you, you should play classic controls mode for a few minutes. This way you can learn what Doom was like in the olden days. You had to hold a button down to enable strafing. You couldn&#8217;t aim up or down. You couldn&#8217;t jump. You had to hold a button to run. You couldn&#8217;t really mouse look. It&#8217;s important to know what it was like so you can fully appreciate the great luxuries we have today.</p>
<p>Now that you know what it was like all those years ago, you don&#8217;t need to suffer like that anymore. Whether you are running Windows, Mac, or Linux, grab yourself a free copy of the <a title="Doomsday Engine" href="http://dengine.net/">Doomsday Engine</a>. Because the Doom engine is open source, many people have rewritten the entire thing to work well on modern computers. Doomsday engine is just one of these, but it has worked very well for me on all three platforms. I recommend it.</p>
<p>Installing the Doomsday engine is pretty straight forward. The only tricky part is that you have to tell it which Doom engine games you own, and tell it the locations of the WAD files. Check off the boxes for every game you have purchased on Steam. If you purchase the id complete pack, that&#8217;s every game except for the demo versions. The WAD files should be located in c:\Program Files (x86)\Steam\steamapps\common\GAMENAME\base\FILENAME.WAD</p>
<p>Just replace GAMENAME with whatever game you are looking for, such as ultimate doom, and replace FILENAME with the filename of the wad file that Doomsday is looking for. The only thing that might be tricky is that the Hexen: Deathkings of the Dark Citadel game actually requires two WAD files. Don&#8217;t worry, they&#8217;re both in the correct folder. If you are running a 32 bit Windows, you can leave off the (x86).</p>
<p>Once you&#8217;ve told Doomsday which games you have, and where the WAD files are, you&#8217;re in modern PC gaming territory. Doomsday&#8217;s configurations are almost exactly like those on every other PC game you are used to. You can select modern resolutions, completely configure your controls, go nuts. You can even do things like add in a mini map that wasn&#8217;t in the original game. The world is your oyster.</p>
<p>Just remember when you&#8217;re playing this old game with the new engine that it&#8217;s not the same as the original. You couldn&#8217;t jump, look up or down, strafe without an extra button, or change weapons with the scroll wheel. It&#8217;s an impure experience, but it&#8217;s good enough for you to learn about the Doom family of games. Most importantly it works, and it won&#8217;t have a person used to modern games quitting in frustration after a few minutes.</p>
<p>One more suggestion. In Totilo&#8217;s article he mentions not finding a shotgun for quite some time. The reason is that he was playing on a sissy difficulty level. He&#8217;s probably too young to die. I suggest you turn up the difficulty, otherwise you really aren&#8217;t going to learn anything. Nightmare is supposed to be nearly unbeatable, but you probably want at least hurt me plenty. If you do that, you&#8217;ll probably be seeing a shotgun toting bad guy right away.</p>
<p>One more hint. If you aren&#8217;t taking out one imp, or two or three regular guys, with one blast from the shotgun, then you&#8217;re doing it wrong.</p>
<p>Prepare to meet your Doom.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/how-to-play-doom/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t Change the Computer, Change Yourself</title>
		<link>http://www.apreche.net/dont-change-the-computer-change-yourself/</link>
		<comments>http://www.apreche.net/dont-change-the-computer-change-yourself/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 17:03:12 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1232</guid>
		<description><![CDATA[Many long years ago, I used to be a Gentoo user. Today I run Windows 7 on every computer I own, and I use default Ubuntu installations on servers and in Virtual machines for development. I went from running one &#8230; <a href="http://www.apreche.net/dont-change-the-computer-change-yourself/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Many long years ago, I used to be a Gentoo user. Today I run Windows 7 on every computer I own, and I use default Ubuntu installations on servers and in Virtual machines for development. I went from running one of the hardest core Linux distros on the bare metal to not running Linux on bare metal at all. That&#8217;s a pretty big change as far as nerds are concerned. What happened?</p>
<p>My first experience with Linux was in the very late &#8217;90s. The first time I saw it, some kids at the <a title="Camp Watonka" href="http://www.watonka.com/cgi-local/wpage">nerd summer camp</a> I went to were running it. I didn&#8217;t use it, and I didn&#8217;t learn it. Yet, as with all things related to computers, I was curious. In high school a friend lent me a Corel Linux CD-ROM. I tried with no avail to make it work on the family computer (486 100mhz). I didn&#8217;t realize I had to boot from the CD-ROM, and I don&#8217;t think that computer even had that capability.</p>
<p>It wasn&#8217;t until 1999 that I downloaded Red Hat ISOs over my 56k dial-up connection. It was the first computer I ever built and personally owned, a Pentium /// 450mhz. I was able to dual boot Red Hat 6.0 and Windows 98SE. The thing is, I soon deleted it. It didn&#8217;t work with my USB dial-up modem. Linux was apparently just a different desktop with some different looking applications, and bad hardware support.</p>
<p>It wasn&#8217;t until I got to college that I actually learned something. All the computer science labs ran Solaris, and I started to learn UNIX for real. I soon discovered Mandrake Linux. It actually worked with all my hardware, even my weird PCI IDE controller. Most importantly, I learned to SSH into the Solaris systems to do my school work, and even use X11-forwarding.</p>
<p>At this point I was hooked. I was running Linux as the primary OS in a dual boot system. I only loaded up Windows (2000) for PC gaming. The thing is, hardware support was still a problem. My hardware didn&#8217;t all work perfectly, and Mandrake didn&#8217;t update quickly enough to give me the updates that fixed those problems. That&#8217;s when I had the distro rodeo and picked Gentoo.</p>
<p>I tried every major Linux distro at the time, and BSD as well. None of them really impressed me, and Gentoo didn&#8217;t even seem to work. Yet, I kept going back to it. The splash screen was so good looking, the community forums were so helpful, and the documentation was so great, that I kept at it. Eventually I came to realize that yes, I actually had installed it properly multiple times over, but unlike other Linux distros X was not a default part of the system. Booting into a command line wasn&#8217;t a failure, it was success.</p>
<p>From then on I was Gentoo crazy. I would constantly be rebuilding packages updating packages, even reinstalling the whole system. I would constantly be tweaking and twisting system settings to see what they did. Mostly I messed around with the user interface. I even fell into using fvwm, the most customizable X window manager. By default it sucked, but if you configured it, you could go beyond anything else in existence. Boy, did I ever configure it.</p>
<p>Late in my college years, and after graduation, I was soon employed. My free time evaporated. I was spending a lot of time commuting to work. My iPod became a lot more important than my desktop. I needed Windows to run iTunes, and to play games. I had little desire to code outside of work. Yet, I still kept a dual booted Linux because it was nicer to SSH into my blog/podcast server from that, than from PuTTY.</p>
<p>By then, I was rocking Ubuntu. It just worked. It installed in 15 minutes, not three days. I didn&#8217;t need to jump through any hoops to get my NVidia card working. I no longer needed to edit the X configuration to get dual monitor support and proper resolutions. I still had a natural inclination to customize the user interface, but it was kept at a minimum simply due to the fact I had no free time for it.</p>
<p>Eventually I was running Ubuntu and Windows. Then my desktop was dual booted, but my laptop was just Ubuntu. And then when I discovered VirtualBox, and it became good enough, I ran Ubuntu on the desktop in a virtual machine, and only had Windows installed on the bare metal. And just recently I replaced that laptop with a new one. This new laptop is so powerful that it too can run Linux in a virtual machine. And thus, my days of installing Linux are over. I wish I could run Linux in the bare metal and Windows in a virtual machine. The thing is that I use Windows for gaming, and VMs are not so great for that. I use Linux for web development, and running it in a VM makes no difference for that at all.</p>
<p>You see, in college I had a ton of free time. I spent that free time working on my computer. I do not regret spending my time in that manner. Most of the Linux skills I use every single day I learned from rocking Gentoo. Even so, I can now look at my old self and laugh. I was not unlike a mechanic who always worked in the garage and never drove anywhere. I spent all that time trying to customize the computer to my preferences, that I hardly ever computed. That&#8217;s why I don&#8217;t have my own software business. While I was compiling and configuring other people&#8217;s code, the other guys were writing that code.</p>
<p>Thankfully I learned my lesson, and I hope you can learn the same. It is often quite difficult to change computers. You can spend hours just customizing keyboard shortcuts, let alone other settings. Then, as soon as you use a different computer, all of your customizations are gone. Even if your customization can increase your efficiency, is it really worth it if it takes you an hour to set it up?</p>
<p>Take it from someone who has been there. Instead of changing the computer, change yourself. It&#8217;s easy to change yourself, you have 100% full control. You don&#8217;t even need to spend time looking up how to do it. Get used to the default keyboard shortcuts instead of making your own. Learn to live with the default settings. Once you do, you can be just as efficient as you would have been with your customizations. Better still, you will be able to sit at any computer and get going immediately without being frustrated at a different setup.</p>
<p>It used to be that my computer felt like home, and every other computer felt like a foreign country. Thanks to cloud computing, any computer with an Internet connection and a web browser can become your home as quickly as you can login. You no longer have to spend a day installing and configuring software after you have a fresh OS install. You just have to install your favorite browser, and maybe one or two other things like Steam or iTunes.</p>
<p>Learning default settings only makes this even easier. I truly feel at home on absolutely any computer I sit in front of. I am familiar with all three major OSes and all the major browsers. I still do not prefer OSX, which I am forced to use at work, but I know it. I&#8217;ve also made vim my text editor of choice, and I use it with a very default configuration. Vim or vi is already installed on almost every system, I can easily use any server I come across. People who are perhaps used to graphical editors, like Eclipse, may have some slight difficulty if they have to SSH into a server and fix something.</p>
<p>If you get frustrated behind the wheel of any car other than your own, then do you really know how to drive? A real driver can sit in any driver&#8217;s seat and be off to the races after a quick seat and mirror adjustment. That&#8217;s not to say you should never spend time under the hood. It&#8217;s very important to know how things work, and to be able to fix them when they go wrong. Just don&#8217;t spend so much time under there that you never leave your garage.</p>
<p>You won&#8217;t get very far in this world by working on your computer. If you want to make it somewhere, you have to use the computer to compute. Start now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/dont-change-the-computer-change-yourself/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Presenting Presentoh, King of Presentations</title>
		<link>http://www.apreche.net/presenting-presentoh-king-of-presentations/</link>
		<comments>http://www.apreche.net/presenting-presentoh-king-of-presentations/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 01:28:17 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1227</guid>
		<description><![CDATA[I do a lot of panels at various conventions. When I do these panels, I need some sort of visual aid. For this I usually turn to Powerpoint, and its alternatives. The thing is, these just plain suck, at least &#8230; <a href="http://www.apreche.net/presenting-presentoh-king-of-presentations/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I do a lot of panels at various conventions. When I do these panels, I need some sort of visual aid. For this I usually turn to Powerpoint, and its alternatives. The thing is, these just plain suck, at least for my purposes. They have a zillion features that allow people to make really bad presentations. Meanwhile, the feature that I really want, which is video, effectively doesn&#8217;t work.</p>
<p>It dawned on me that because of HTML5, it should actually be possible to create an HTML presentation with video that is seamless. Today I went ahead and prepared a video-centric panel for Connecticon, and I did it all in HTML5. I realized afterwards that I should build this into a tool, so that others can use it as well. Hence, Presentoh was born.</p>
<p><a title="Presentoh" href="http://github.com/Apreche/Presentoh">http://github.com/Apreche/Presentoh</a></p>
<p>The idea is really simple. There are only four kinds of slides I think you should be using: title slides, bulleted lists, videos, and images. I built a simple HTML template which could handle all four types of slides. I made a brain-dead simple CSS style for it which entails white text on black background. The black background also looks more professional because photos and videos really stand out. Also, it looks better when using a projector in a dark room because you can&#8217;t see the borders of the projection.</p>
<p>The only catch was that I wanted to use my Logitech Cordless Presenter. I went out and found jquery.hotkeys, which allowed me to bind any key on the keyboard to move between slides by redirecting in JavaScript. Problem solved.</p>
<p>All you have to do to use Presentoh is create a file containing JSON which defines all the slides in your presentation. Then you just run the presentoh.py script, tell it which json file you want to use, and it spits out all the HTML files for your presentation. Find the first slide in your presentation, open it in your browser, go full screen, and rock and roll.</p>
<p>I think it&#8217;s pretty awesome that while this tool is really hacky, and doesn&#8217;t have any error checking, it still beats out Google Docs, Powerpoint, Open Office, and all the rest in terms of how it handles video. There are some slight catches, but nothing that can&#8217;t be worked around. For example, you have to make sure all of your videos are the right codec for the browser you are using. My H.264 videos obviously didn&#8217;t work in Firefox.</p>
<p>Also another issue is that there is no way to automatically make an HTML5 video go full screen. If you&#8217;re wondering why, <a title="HTML5 full screen video" href="http://stackoverflow.com/questions/1055214/is-there-a-way-to-make-html5-video-fullscreen">the answer is on stackoverflow</a>. Therefore you have to manually specify the height and/or width of each video depending on its aspect ratio, and the resolution you will be presenting in. This is to prevent videos from going off the edges of the screen if they are too wide or too tall, and to prevent aspect ratios from being broken.</p>
<p>All the rest of the information can be found in the README file. I hope Presentoh helps somebody out there with their presentation needs. Enjoy.</p>
<p><!--79ae0a991e384da09696961d2702f294--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/presenting-presentoh-king-of-presentations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GitHub Suggested Workflow</title>
		<link>http://www.apreche.net/github-suggested-workflow/</link>
		<comments>http://www.apreche.net/github-suggested-workflow/#comments</comments>
		<pubDate>Thu, 06 May 2010 02:28:31 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1198</guid>
		<description><![CDATA[The thing that&#8217;s great about Git is that it allows the user to pick any work flow they desire. The problem is that it allows the user to pick any work flow they desire. Thus, users who don&#8217;t know exactly &#8230; <a href="http://www.apreche.net/github-suggested-workflow/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The thing that&#8217;s great about Git is that it allows the user to pick any work flow they desire. The problem is that it allows the user to pick any work flow they desire. Thus, users who don&#8217;t know exactly what they want to do, are confused as to what they should do. Github makes things even worse, as it confuses users with lots of extra information.<span id="more-1198"></span></p>
<p>I have recently started a new project, Project D.O.R.F., and many of the other developers are new to Git. Thus, they have been making some mistakes and not utilizing Git to its fullest. Thus, I have created this guide using Project D.O.R.F. as an example. As you become more experienced with Git, you can figure things out on their own. Until then, this flow will get you a very long way.</p>
<p>Assuming you have Git installed properly, the first thing you need to do is configure Git. It is done like so.</p>
<p><code>$ git config --global user.name "Your Username"<br />
$ git config --global user.email "your@email.com"</code></p>
<p>These two commands will configure your username and e-mail address for every Git repository you work on with that user account on that machine. Every commit in a Git repository has an author, so this is necessary to see which people are responsible for what work. There is also a git blame command that can show who is responsible for each individual line of code in a repository. If these settings are not configured, those features will not work. Alternatively, you can change these settings on a per-repository basis, but I&#8217;ve never had a need for it.</p>
<p>The next step is to go to GitHub and create a fork. First you go to <a href="http://github.com">http://github.com</a> and register for it, as you would any other web site. There is no need to pay any money unless you would like to have private repositories that nobody else can access. Next go to the GitHub page for the project you would like to work on, in this case it is <a href="http://github.com/Apreche/Project-DORF/">http://github.com/Apreche/Project-DORF/</a>. Then, click the fork button. This will create a copy of the project in your GitHub account. You can see that lackofcheese has a fork of the project at <a href="http://github.com/lackofcheese/Project-DORF/">http://github.com/lackofcheese/Project-DORF/</a>.</p>
<p>Now that you have your own personal fork of the project, you need to actually get the code onto your local machine to begin working on it. This is done with the git clone command. Remember, you want to clone your forked repository, not the original one. You also want to clone using the SSH method. Follow the directions on GitHub for configuring your SSH key.</p>
<p><code>$ git clone git@github.com:yourusername/Project-DORF.git</code></p>
<p>This command will create a folder named Project-DORF which contains a clone of the repository. If you would like to put the repository into a different folder, feel free to move or rename it. Alternatively, you can do something like this which will put the repository in a directory named foobar</p>
<p><code>$ git clone git@github.com:yourusername/Project-DORF.git foobar</code></p>
<p>So now it&#8217;s time to get to work. Go into the folder and take a look at the files, and learn the project. You&#8217;ve got to read code before you can write it.</p>
<p><code>$ cd Project-DORF</code></p>
<p>You&#8217;ve read the code, and you&#8217;re ready to make some changes, but wait! What branch are you on? Let&#8217;s check.</p>
<p><code>$ git branch<br />
* master</code></p>
<p>The master branch, you don&#8217;t want to be working directly on the master branch. Do all of your work on separate branches. And if you are working on more than one task, put each task in a separate branch. For example, let&#8217;s say you are planning to improve performance of the renderer, but also fixing a bug in a path-finding algorithm. Don&#8217;t do those things on the same branch. Do them separately. That is the power and magic that Git has to offer you, so there&#8217;s no point if you don&#8217;t use it. We&#8217;re going to fix a bug on a separate branch, let&#8217;s go.</p>
<p><code>$ git checkout -b bugfix<br />
$ git branch<br />
* bugfix<br />
master</code></p>
<p>Perfect, we have a new branch. Now, start coding! Are you done coding? Time to commit. Let&#8217;s pretend we edited game.py, and we made a new file foo.py.</p>
<p><code>$ git status<br />
# On branch bugfix<br />
# Changed but not updated:<br />
#   (use "git add <file>..." to update what will be committed)<br />
#   (use "git checkout -- </file><file>..." to discard changes in working directory)<br />
#<br />
#	modified:   game.py<br />
#<br />
# Untracked files:<br />
#   (use "git add </file><file>..." to include in what will be committed)<br />
#<br />
#	foo.py<br />
no changes added to commit (use "git add" and/or "git commit -a")</file></code></p>
<p>It seems like git recognizes that we have a new file, but it&#8217;s untracked. It also recognizes we have modified game.py, but it&#8217;s not updated yet. You can see that there are instructions right there on the screen as to how to commit our changes. We can checkout a file to reset it to its pre-edited state. This command will undo our changes to game.py.</p>
<p><code>$ git checkout -- game.py</code></p>
<p>But we want to commit our changes, which means adding them first. We can explicitly add the files with the git add command.</p>
<p><code>$ git add game.py<br />
$ git add foo.py</code></p>
<p>Then we can commit the changes with the git commit command.</p>
<p><code>$ git commit</code></p>
<p>Let&#8217;s say you only want to commit some of the changes, but not others? That&#8217;s perfectly fine. Just add the files you want to commit, and don&#8217;t add the files you don&#8217;t want to commit. Protip: Use the special commands like:</p>
<p><code>$ git add -i<br />
$ git add -p</code></p>
<p>to interactively select line-by-line which changes you want to add. If you add two bits of code to a file, and only want to commit one of them, then only commit one of them. Nothing is stopping you.</p>
<p>The thing is, most of the time you are working, you aren&#8217;t making new files. You are just editing existing ones, and you want to commit all of your changes. In these cases use this shortcut command.</p>
<p><code>$ git commit -a</code></p>
<p>This will automatically add and commit all changes to files that already exist. You will still need to explicitly use the git add command to add in any newly created files. You will also need to use the git rm command to remove files. If you move or rename a file, just be sure to git add the new one and git rm the old one in the same commit, and git will figure it out, like magic. git rm is just like git add, so you have to commit afterwards. You should also use commands such as <code>git add -A</code> and <code>git add -u</code> to easily add many files at once. See the official Git documentation for more on that.</p>
<p>You&#8217;ve got your code in a separate branch from master, and you&#8217;ve committed your changes. Now it&#8217;s time to share them with the world. But first, you&#8217;ve got some work to do. While you were working, other people were also on the job. There is probably new code out there, and you have to make sure that your code plays nicely with it. The first thing you have to do is to add the canonical repository for the project as an upstream source. You only have to do this command once per clone.</p>
<p><code>$ git remote add upstream git://github.com/Apreche/Project-DORF.git</code></p>
<p>You don&#8217;t have to call it upstream, you can call it whatever you like, but upstream is an appropriate name. Regardless, this command creates the hook you need to be able to get updates from the &#8220;lead&#8221; repository. How do you get those updates? Let me tell you.</p>
<p>There are three commands you have to be concerned with here: fetch, merge, and pull. Fetch will get the new patches from the remote repository. Merge will merge those patches into your current branch. Pull does both at the same time. Let&#8217;s do it.</p>
<p>Go back to the master branch.</p>
<p><code>$ git checkout master</code></p>
<p>Fetch and merge changes from the upstream master into your local master.</p>
<p><code>$ git pull upstream master</code></p>
<p>Ok, so now your master branch has all the latest goodies that everyone else has been working on. But are your changes compatible? Let&#8217;s find out. </p>
<p>Switch back to your bugfix branch.</p>
<p><code>$ git checkout bugfix</code></p>
<p>Rebase!</p>
<p><code>$ git rebase master</code></p>
<p>Rebase can be a scary thing, but it&#8217;s not scary if you are careful. In this case, what we are using it for is pretty simple. It takes your changes that you have made on your bugfix branch, and sets them aside. Then it takes all the new goodies from the master branch, and puts them on your bugfix branch. Then it takes your changes and puts them back on top of that. If there is a conflict, it will provide you with instructions on how to fix it. Git has three different merging algorithms, though, so that rarely happens. Now that you are all rebased, test your branch and make sure it works. If changes are necessary, go back a few steps. Add and commit the changes. Make sure upstream doesn&#8217;t have any new changes. If it does, rebase again, and so on. Eventually, you will have a bugfix branch worthy of sharing with the world. Let&#8217;s do it.</p>
<p><code>$ git checkout master<br />
$ git merge bugfix<br />
$ git push</code></p>
<p>You&#8217;ve now pushed your changes out to your GitHub page. Congratulations. Now the rest of the world can go to your page and see those changes. Other people working on the project might even take your changes and start fiddling with them themselves. Don&#8217;t worry about that, though. You are interested in getting your changes upstream into the canonical repository. So go back to the GitHub web site for your repository, and click the pull request button. Send a pull request out to your collaborators, in this case Apreche, and they will be notified that your changes are ready for merging. Wait patiently, and if your patches are good, they will be part of the upstream. More information on pull requests is available at <a href="http://github.com/guides/pull-requests">http://github.com/guides/pull-requests</a></p>
<p>Now let&#8217;s get advanced for a second. Git really doesn&#8217;t believe in the idea of a canonical repository. It&#8217;s just a concept we use to make things easier for ourselves. Someone coming to GitHub for the first time is going to see 10 repositories with similar code, how do they know which one is the right one? This is why picking one to be <b>the</b> one is a good idea. However, since there really is no such thing, you can actually do some fancy stuff. You might want to use the git remote add command to add links to some of the other contributors on the project. For example, lackofcheese might do this to be able to fetch amelim&#8217;s changes that are not yet available at upstream.</p>
<p><code>$ git remote add amelim git://github.com/amelim/Project-DORF.git<br />
$ git fetch amelim<br />
$ git merge amelim/master<br />
</code></p>
<p>It also might be a good idea to merge different contributor&#8217;s patches into separate local branches which you then merge together. Never be shy about making a ton of local branches. You can delete the ones you are no longer using to clean up cruft, and the cost of making them is very minimal. Don&#8217;t hold back, branch like a mad man. Here&#8217;s an example of how I would merge changes from two other contributors with my code and then push it out on the master branch. When I was done with this, I would send out a pull request.</p>
<p><code>$ echo "These remote add commands only need to be done once ever per clone"<br />
$ git remote add ameleim git://github.com/amelim/Project-DORF.git<br />
$ git remote add lackofcheese git://github.com/lackofcheese/Project-DORF.git<br />
$ git checkout -b mycode<br />
$ git add somefiles<br />
$ git commit<br />
$ git checkout -b cheese<br />
$ git fetch lackofcheese<br />
$ git merge lackofcheese/master<br />
$ git checkout -b melim<br />
$ git fetch amelim<br />
$ git merge amelim/master<br />
$ git rebase cheese<br />
$ echo "The melim local branch now has amelims changes merged with lackofcheese's"<br />
$ git checkout mycode<br />
$ git rebase melim<br />
$ git checkout master<br />
$ git merge mycode<br />
$ git push<br />
$ echo "mycode on top of amelim's on top of lackofcheese's pushed out to the world"<br />
$ echo "let's delete the branches we are done with<br />
$ git branch -D mycode<br />
$ git branch -D cheese<br />
$ git branch -D melim</code></p>
<p>When you execute the rebase commands, you may be prompted to fix conflicts. If so, just follow the directions on the screen carefully. They usually involve editing the files in question with your editor to fix the appropriate sections by hand, re-adding, and re-committing the changes. It doesn&#8217;t happen often, and it&#8217;s not nearly as hard as it is to fix with non-distributed version control systems. Just make sure to test your code after resolving he conflicts.</p>
<p>That pretty much covers my basic work flow. Just to reiterate. Make separate local branches. Do work on them. Pull (fetch and merge) the upstream changes to your master branch. Rebase your changes on top of master then merge them into master before pushing them out to the world. If necessary, pull the changes of other collaborators into separate branches, and rebase/merge their changes together. Then take the sum of those changes and treat them as you would your own. Rebase them on top of the upstream master, merge them in, and push them out. </p>
<p>I have followed this work flow for quite some time, and it has served me well. Feel free to ask any question. Happy coding.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/github-suggested-workflow/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>iPad: Why Must We Be Forced To Choose?</title>
		<link>http://www.apreche.net/ipad-why-must-we-be-forced-to-choose/</link>
		<comments>http://www.apreche.net/ipad-why-must-we-be-forced-to-choose/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 17:00:26 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1193</guid>
		<description><![CDATA[There is, of course, the expected hoo-hah about the iPad. The rage between those who love it and those who can&#8217;t stand its proprietary nature is in full swing. Yet, I am constantly in awe of the fact that nobody &#8230; <a href="http://www.apreche.net/ipad-why-must-we-be-forced-to-choose/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>There is, of course, the expected hoo-hah about the iPad. The rage between those who love it and those who can&#8217;t stand its proprietary nature is in full swing. Yet, I am constantly in awe of the fact that nobody seems to notice the obvious and simple cause of this clash.<span id="more-1193"></span></p>
<p>It all comes down to one thing. Why must we be forced to choose between a good user experience and openness? How come we can&#8217;t have both? Every open platform has a god-awful user interface, relatively speaking. All Apple products, especially the portable devices, have a great user experience. I don&#8217;t personally like OSX, but I can&#8217;t deny that it gets a lot of things right that everyone else gets wrong. Font rendering is a good example.</p>
<p>People who don&#8217;t care about openness, or aren&#8217;t aware of the problem, are thrilled. They get everything they want. Hooray for them. People who do care about openness are enraged. Why are they mad about something they aren&#8217;t going to buy or use? This is easy to explain.</p>
<p>They are mad because they see an unfulfilled potential. Think of a screwdriver. A typical screwdriver can screw any screw that is of appropriate size. Imagine a copper screw and a steel screw that are otherwise identical. For some reason the screwdriver works on the steel screw but not the copper one for no apparent reason. I think most people would consider such a screwdriver to be broken.</p>
<p>A device like the iPad has all the hardware necessary to do a billion amazing things. However, it only does a few thousand things. Why? Because Steve Jobs says so. Who is he to tell me what I can and can&#8217;t do with this thing that I have bought? If you compare it to the screwdriver example, you can say that the iPad/iPhone/iPod are all broken. Broken technology enrages the geek, especially when they can&#8217;t fix it.</p>
<p>The nerd goes out to get a different screwdriver that is not broken. All these other screwdrivers are great. They work on all screws, as expected. However, they all have really uncomfortable handles. Every single screwdriver out there which is not broken is really uncomfortable. There is not a single exception.</p>
<p>Why can&#8217;t someone just take the good screwdriver and stick it on the comfortable handle? It&#8217;s so simple. There is no law of physics preventing it from happening. It&#8217;s 100% possible, but for whatever reason it just doesn&#8217;t exist. Every single screwdriver on the shelf is either broken or uncomfortable. The geeks can not be satisfied. Their rage multiplies exponentially.</p>
<p>This is the source of the rage against Apple. Apple seems to be the only company capable of making screwdrivers with comfortable handles, but their screwdrivers can&#8217;t do half of the things that other cheaper screwdrivers can do. Meanwhile, all those other cheaper screwdrivers give you blisters when you use them. I&#8217;m getting angry just thinking about this imaginary screwdriver scenario. </p>
<p>There are only two solutions I see. One is that Apple opens up. Apple is clearly capable of open sourcing things. They could just open their portable hardware and software, and that would be that. Obviously it will never happen, but I don&#8217;t understand why. If Apple did it, they would have immediate complete market dominance. If they had a comfortable and fully featured screwdriver, all competition would crumble instantly. There would be no reason to buy any competitor&#8217;s product.</p>
<p>The other solution is for the open source people to just shamelessly start ripping Apple off. If we can&#8217;t invent something better, which we clearly can not, then let&#8217;s reverse engineer and straight-up steal all of Apple&#8217;s stuff. Take the screwdriver handle down to the metal shop, copy it exactly, and attach it to a real screwdriver. Patent laws my ass. Why should we settle for anything less than achieving our full technological potential? Patents are supposed to help, not hinder, progress. If they are hindering, let&#8217;s just ignore them.</p>
<p>Google, I&#8217;m looking at you. You must know that Android&#8217;s UI sucks compared to iPhone. You have a jillion dollars. Just hire the best designers in the world, and get it done. What are you waiting for? You&#8217;re supposed to be a company of geniuses, why didn&#8217;t you just do this in the first place for Android 1.0? What can you possibly be thinking? What are all the non-Apple companies thinking? </p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/ipad-why-must-we-be-forced-to-choose/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Why Gaming Won&#8217;t Save The World</title>
		<link>http://www.apreche.net/why-gaming-wont-save-the-world/</link>
		<comments>http://www.apreche.net/why-gaming-wont-save-the-world/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 20:23:08 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Video Games]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1163</guid>
		<description><![CDATA[...being a virtuoso at World of Warcraft is like being a virtuoso at the player piano. <a href="http://www.apreche.net/why-gaming-wont-save-the-world/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In <a href="http://www.ted.com/talks/jane_mcgonigal_gaming_can_make_a_better_world.html">this TED Talk</a> Jane McGonigal presents the idea that gaming can be used to change the world. People are playing games for billions of hours. Kids growing up today spend so much time playing games, they are virtuosos at it. Therefore, we can use the incredible amount of skill they have built up and direct it towards world-changing activities for the betterment of everyone.</p>
<p><center><!--copy and paste--><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="446" height="326" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="wmode" value="transparent" /><param name="bgColor" value="#ffffff" /><param name="flashvars" value="vu=http://video.ted.com/talks/dynamic/JaneMcGonigal_2010-medium.flv&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/JaneMcGonigal-2010.embed_thumbnail.jpg&amp;vw=432&amp;vh=240&amp;ap=0&amp;ti=799&amp;introDuration=16500&amp;adDuration=4000&amp;postAdDuration=2000&amp;adKeys=talk=jane_mcgonigal_gaming_can_make_a_better_world;year=2010;theme=art_unusual;theme=design_like_you_give_a_damn;theme=new_on_ted_com;theme=media_that_matters;theme=the_rise_of_collaboration;theme=what_s_next_in_tech;theme=a_taste_of_ted2010;event=TED2010;&amp;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" /><param name="src" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" /><param name="bgcolor" value="#ffffff" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="446" height="326" src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" flashvars="vu=http://video.ted.com/talks/dynamic/JaneMcGonigal_2010-medium.flv&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/JaneMcGonigal-2010.embed_thumbnail.jpg&amp;vw=432&amp;vh=240&amp;ap=0&amp;ti=799&amp;introDuration=16500&amp;adDuration=4000&amp;postAdDuration=2000&amp;adKeys=talk=jane_mcgonigal_gaming_can_make_a_better_world;year=2010;theme=art_unusual;theme=design_like_you_give_a_damn;theme=new_on_ted_com;theme=media_that_matters;theme=the_rise_of_collaboration;theme=what_s_next_in_tech;theme=a_taste_of_ted2010;event=TED2010;&amp;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" bgcolor="#ffffff" wmode="transparent" allowfullscreen="true"></embed></object></center>
<p>The talk itself is insightful, and the research Jane is doing at the <a href="http://www.iftf.org/">Institute For The Future</a> is very interesting. I especially enjoyed the part of the talk where she discussed Herodotus&#8217; story of the Lydians using dice games to ease famine possibly being true. It at least rings true considering the use of video games to distract ill people from their pain and suffering.</p>
<p>Regardless of that Jane&#8217;s talk seems to gloss over many obvious factors. Mainly she completely fails to deeply analyze the mechanics of the games themselves. The sad fact is that games can not change the world, at least not in the way she presents.</p>
<p><span id="more-1163"></span></p>
<p>In the talk, Jane says that in games people present the best version of themselves. Players will never quit until their goals are achieved. Not only that, but they give their strongest effort, and are ready and willing to collaborate. If you ignore the griefers and <a href="http://www.penny-arcade.com/comic/2004/03/19/">shitcockers</a> out there, this is largely true. What she doesn&#8217;t discuss very deeply are the reasons behind these behaviors.</p>
<p>The simple and obvious reason is that games have no true failure. If someone tries to be a hero in real life, and they fail, there are permanent negative consequences. In the real world, you risk losing your money, possessions, freedom, health, and the health of those you care for. It&#8217;s a dangerous world, and many mistakes can not be undone. This is the cause of the anxiety people feel in the real world that they do not have in the game world.</p>
<p>In the gaming world there is a reset button. Even if you fail, you can keep trying with no repercussions other than lost time. In Mario, you don&#8217;t feel much anxiety trying to jump over the gigantic pit because you have extra lives. If you&#8217;re down to your last life, then you actually do feel some anxiety because failure means having to start over from the beginning again. When games do actually have negative consequences for failure, players get upset and play something else.</p>
<p>I think the reason she misses this is because she focuses on World of Warcraft, a game with no consequences. Death isn&#8217;t even a real consequence in WoW, or other modern MMORPGs. It&#8217;s just a momentary obstacle that can be completely reversed. Take a look at some other games out there that actually have harsh consequences for failure. How about some old NES games that have no continues, passwords, or extra lives? How about Steel Battalion which would erase your save data if you failed to eject on time? These games are obviously ludicrously unpopular.</p>
<p>As for the topic of virtuosos and 10,000 hours of practice, I personally don&#8217;t buy it. Measures of talent are strictly relative. How many people out there have played over 10,000 hours of golf or tennis? Now how many Tiger Woods and Roger Federers are out there? How many people in South Korea have played that much Starcraft? What percentage of them are professionals? I know I personally have played many thousands of hours of video games, but you don&#8217;t see me sponsoring PC hardware like Fatal1ty. The first person to ever play the violin was a virtuoso in their time, though they would be terrible by today&#8217;s standards. Being a virtuoso simple means you are better than everyone else. Not everyone can be great. That&#8217;s what makes greatness great.</p>
<p>This fact directly interferes with the factor of epic purpose. Every person who plays Zelda to the end will defeat Ganon and save the world of Hyrule. In the real world, there is only one champion, and it&#8217;s probably not you. Even if you collaborate and give your full effort, odds are you will still fail to be exceptional in the real world. Tons of people around the world dedicate their lives to sports, music, and other things from a young age. A ludicrously small percentage make it big. Strong effort greatly facilitates great achievement, but does not guarantee it.</p>
<p>For the sake of discussion, let&#8217;s imagine that everyone actually can be a virtuoso. We&#8217;ll pretend that we can create an army of Steve Vai&#8217;s by practicing enough guitar. If that is true, then being a virtuoso at World of Warcraft is like being a virtuoso at the player piano. If an activity has no possibility of failure, then either every human being is a virtuoso at it, or none are, regardless of how much practice. It&#8217;s meaningless and unremarkable to be a virtuoso at an activity at which you are guaranteed to succeed. If every scientist got  Nobel Prize, it would lose all meaning.</p>
<p>Let&#8217;s take this same exact TED Talk, and replace all of the World of Warcraft examples with Counter-Strike. People are not ready and willing to collaborate in Counter-Strike, often prioritizing personal kill ratios above the objectives of the team. They will not work hard towards their goal, often switching servers when faced with a superior opponent they can not beat. People are quick to cheat their way to victory because true victory is too much work, if it&#8217;s even possible. Most players quit and never try again when they can not achieve success with minimal effort. These are the same people that quit in real life. They are the boomerang generation running home to mommy because college is too rough. Sorry, I don&#8217;t believe that these people can save the world.</p>
<p>If you want to really change the world with games, you need games that mimic the real world. These are known as simulations. The military uses them to train people for various things, most notably flight. If you play a racing simulator for 10,000 hours as a child, you do actually have a good chance of becoming a professional race car driver. The thing is, an accurate simulation is just as difficult as driving a real race car, and will not attract many players putting in many hours. Tons of people play Mario Kart. Relatively few have even heard of Forza or Gran Turismo. If you could get people to play simulation games as much as they play Bejeweled, then you could change the world. Sadly, that will never happen because simulations are simply not fun to most people. This is why rhythm games have ludicrously simplified instruments. They make rhythm games with real instruments, and almost nobody plays them.</p>
<p>I do think that making the real world more like a game can save it. Make it impossible to fail at life. Give straight A+ grades to every student just for showing up to class. Remove all negative irreversible consequences from everything. Guarantee success for anyone who puts in enough effort, regardless of skill or talent. Do all that, and an army of gamers will revolutionize the real world. Then again, does such a utopian world really need changing?</p>
<p>Until then, I think this talk is actually kind of harmful. A lot of people who are otherwise wasting their lives away will use this to validate that time wasting. Some may falsely believe that they are saving the real world while saving Azeroth. Rather than changing the world with games, it may just be giving people another excuse to play games when they could be saving the world.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/why-gaming-wont-save-the-world/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Power Signaling Over HDMI</title>
		<link>http://www.apreche.net/power-signaling-over-hdmi/</link>
		<comments>http://www.apreche.net/power-signaling-over-hdmi/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 00:53:16 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Ideas]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1155</guid>
		<description><![CDATA[Lots of people these days have home entertainment systems. These usually consist of a television, an audio system, and multiple source devices. The source devices typically include a DVD/Blu-Ray player, a Cable Box, one or more game consoles, maybe a &#8230; <a href="http://www.apreche.net/power-signaling-over-hdmi/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Lots of people these days have home entertainment systems. These usually consist of a television, an audio system, and multiple source devices. The source devices typically include a DVD/Blu-Ray player, a Cable Box, one or more game consoles, maybe a computer, and maybe even something like the Roku. Despite these systems being incredibly common, almost nobody knows how to use them. I have an idea which can make things much much easier for everybody.<span id="more-1155"></span></p>
<p>The fundamental problem is that people do not understand the concept of switching inputs. They simply do not get it that video and audio are separate. They don&#8217;t get that the audio and video come out of one box into another box. They do not comprehend that on the receiving box you must manually select which input you wish to currently be active. Now, people should learn this, but with a change to the HDMI spec, I think we can eliminate the problem in the long run.</p>
<p>Every cable box I have seen has a power outlet on it. Why is that? The reason is that you are supposed to plug your television into the cable box, and then plug the cable box into the wall. This will allow you to have the TV turn on and off when you turn the cable box on and off. Ideally this will eliminate the need for the TV remote control. Sadly, this only makes trouble in a more complicated system. For one thing, it means I have to turn the cable box on in order to play a video game. That&#8217;s just a waste of electricity.</p>
<p>The solution is to add one single additional wire to every HDMI cable. That wire will allow the devices to tell each other if and when they are on or off. The devices will also be able to command each other to turn on or off, or to switch inputs. It&#8217;s really so simple, I&#8217;m amazed it doesn&#8217;t already exist.</p>
<p>Here is an example scenario. You have a TV with an XBox and a DVD player. They are all off. You turn on the XBox. The XBox signals over the wire to the TV that it has turned on. The TV notices that it is off, so it turns on. Then it notices the XBox is the device which told it to turn on, and is the only device sending a signal. Therefore it automatically switches to that input. </p>
<p>Think about the difference that makes for the end user. They push the green button on the XBox controller, and they&#8217;re good to go. No fiddling with other remote controls. No juggling inputs. No nothing. Logitech probably wouldn&#8217;t like it, though, because it would ruin their Harmony product line.</p>
<p>I&#8217;m sure that you intelligent readers can figure out how the system will work in all sorts of other typical situations, but let me make a couple more examples. You turn off the TV, and it tells everything connected to it to turn off as well, saving lots of electricity. You turn off the XBox, and nothing else connected to the TV is still on, so the TV turns itself off. You have the XBox already on, but you turn on the Blu-Ray player. Well, it would be worse to switch away from a game in progress, so it should stay on the XBox. However, if the XBox turns off, it can switch to the Blu-Ray automatically. </p>
<p>Of course, the user will still need the ability to take manual control over which inputs are active, because the automatic setting will not be able to handle every single use case. Even so, such a system will drastically decrease the amount of times the user will have to manually switch inputs or turn devices on or off. It will also drastically reduce electricity usage because devices will almost never be on when they are in use.</p>
<p>Now, there are some extremely complicated situations that require figuring out. The best example I can think of is picture in picture. The TV and/or receiver has to be aware that picture in picture is a possibility. Maybe if you have picture in picture, and you turn on a second device, it opens in the small picture. Then if you turn off the second device, the small picture disappears. Even this complicated situation isn&#8217;t that difficult, you just have to spend some time figuring out the best possible default behavior for every possible scenario.</p>
<p>They&#8217;re adding all sorts of other great features to the HDMI specification like Ethernet, higher video resolution, audio return, etc. Those are far more complex than this simple one-wire feature. It will cost next to nothing to implement, and it will make a huge difference. There&#8217;s no rush, we can just do the usual thing we do with car safety equipment. All new products as of X date must support this feature. It will save a ton of electricity and reduce a ton of headaches. Too bad I&#8217;m just some guy and not an electronics manufacturer. I don&#8217;t even know the second step towards trying to make this a reality. The first step was this blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/power-signaling-over-hdmi/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>People Still Don&#8217;t Get Git</title>
		<link>http://www.apreche.net/people-still-dont-get-git/</link>
		<comments>http://www.apreche.net/people-still-dont-get-git/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 19:28:05 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1151</guid>
		<description><![CDATA[I&#8217;ve been using Git since slightly before it became very popular about two years ago. Nowadays it is very popular, with much thanks to github. However, even semi-famous programmers like Jeff Atwood don&#8217;t really understand what it&#8217;s all about. I &#8230; <a href="http://www.apreche.net/people-still-dont-get-git/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been using Git since slightly before it became very popular about two years ago. Nowadays it is very popular, with much thanks to <a href="http://www.github.com">github</a>. However, even semi-famous programmers like <a href="http://www.codinghorror.com">Jeff Atwood</a> don&#8217;t really understand what it&#8217;s all about.<span id="more-1151"></span></p>
<p>I think the primary thing that confuses people about Git is that it assumes that if you are developing software on a team, that you actually talk to people. Whether it&#8217;s by IM, IRC, a web site, Twitter, Git doesn&#8217;t care. It just assumes that you actually have some form of regular communication with the other developers. </p>
<p>You see, the non-distributed version control systems do not make this assumption. If you are using subversion, your work flow is dictated by the limitations of the software. You do some code. When you commit, you also share. Everyone commits to the same place. </p>
<p>With this sort of system, you don&#8217;t need to talk to the other developers to know what to do. There is only one canonical current version of the code in one repository. If you do an svn update, you know everything you need to know. If you change the code, you just commit, and you don&#8217;t need to tell anybody. They will see your changes when they eventually do an svn update.</p>
<p>This system inevitably leads to the many problems that Git solves. The one I always like to point to is the situation where you need to make a quick bug fix while you are in the middle of working on a big new feature. You need to make a version of your code that has the fix, but not the new feature. If you committed the feature, it&#8217;s going to be a nightmare to get a version of the code without it. If you didn&#8217;t commit the feature, it is very hard to collaborate with others. Branching solves it, but branching in subversion is slow and difficult, and it&#8217;s shared. You might ruin everyone else in the process.</p>
<p>Git lets you do absolutely anything that is possible to do with your code. You can branch, tag, commit, share, patch, and unpatch your code any which way you can imagine, and some you can&#8217;t yet imagine. As long as you are aware of all the commands and features, you can never dig yourself into a hole. You will always be able to deliver the code with the combination of  patches that you need. </p>
<p>The problem with this is that since you have so many capabilities, there is no dictated work flow. Should you have a central repository? Should you push back and forth between individual developers? Should we have any shared branches? Should we use tags? Should you use soft tags or hard tags? Should you merge? Should you rebase? All of these questions, and more, are the subject of much debate. </p>
<p>I think that all of these debates are silly. The correct answer is that there is no correct answer. All of the features of Git are just tools to help you get your code the way you need it to be. If rebasing saves the day, then rebasing is awesome. If sending patches by email works for you, then that&#8217;s also awesome. Whatever process you come up with for your team to work together on the same code is fantastic, if it works for you. </p>
<p>Even if you decided to follow a subversion style of development, you can absolutely just do it with Git instead. Git can work exactly the way SVN works, if you wish it to. The best part is that you can use it exactly like SVN, but because it is Git, you can escape the usual SVN traps when they come up. Therefore, I see absolutely no reason for a new project to use SVN when you can simply use Git and have developers agree to work in an SVN flow.</p>
<p>And that is the beauty of Git, is that it lets you come up with your own process. How you work is no longer dictated by the limitations of the software you are using. It is decided by the developers themselves. And even if developers like to work differently, as many do, they can each work in a way that is comfortable for them without interfering with anyone else. As long as the team communicates with each other, and agrees on how to share code, all is well. </p>
<p>Just to drive the point home, Git was made by Linus Torvalds to use for developing the Linux Kernel. How do you submit a patch to the kernel using Git? You put your patch up in your Git repository, and you email someone requesting them to pull the patch from you. Email!? With SVN you just commit, no need to talk to anybody. I don&#8217;t know about you, but do you think that forcing code changes on other developers without having to talk about it a good idea?</p>
<p>If you actually bother to talk to people then <a href="http://twitter.com/codinghorror/status/8057809501">500+ forks</a> is not a problem. You ask someone and they tell you what fork to clone. Just ignore all those graphs, they mean nothing.</p>
<p>However, I must admit that the 500+ forks is indeed a symptom not of Git itself, but github&#8217;s design, and users not understanding Git. Github makes the fork button very prominent, but forking a project on Github is not really something that people should do that often. Github is not Git. The design of Github, intentionally or unintentionally, leads users into doing something they don&#8217;t actually want to do. It doesn&#8217;t really help people understand Git, and it doesn&#8217;t help people communicate.</p>
<p>What most people should be doing is just cloning repository to their local machines, and making changes there. If they want to submit the changes, then they should use non-Git communication tools to talk to the person they cloned from. They only need to fork on github if they want to publicly share changes that have not yet been, or will not be, merged into the actual project. Otherwise, they should not fork, just clone.</p>
<p>If you do have changes that are not accepted, then sharing them publicly on github in a fork is a very useful thing. Maybe there is someone out there who needs a copy of <a href="http://github.com/fastsoft/djata">djata</a> with a slight tweak, but someone else made the tweak already. The tweak may never be accepted to the canonical codebase, but it can still be made available in a form. That might save someone the time of making that same tweak themselves on their own, which is what they would likely be doing on a project managed by subversion.</p>
<p>Right now I see people with SVN mindsets who won&#8217;t switch to Git because they don&#8217;t truly understand DVCS. Likewise there are people with SVN mindsets who don&#8217;t understand DVCS who switch to Git anyway for whatever reason. The missteps of the latter group provide many of the stories that will keep the former group scared away.</p>
<p>All in all, I&#8217;m not too worried. When I was in college, less than a decade ago, the CS department taught us RCS and the software engineering department taught us CVS. In my senior years some people starting using SVN, which was bleeding edge at the time. Git was released in 2005. The world of version control moves surprisingly rapidly. I think Git&#8217;s dominance is pretty much guaranteed at this point. It will just take time for programmers to escape the SVN mindset and understand the, admittedly more complicated, DVCS world. </p>
<p>We Git users are here to help, so ask before you run away or jump to conclusions. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/people-still-dont-get-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Strict Open Source Policies Lead to Fail</title>
		<link>http://www.apreche.net/strict-open-source-policies-lead-to-fail/</link>
		<comments>http://www.apreche.net/strict-open-source-policies-lead-to-fail/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 18:25:26 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1148</guid>
		<description><![CDATA[Ubuntu and Firefox are two of the biggest open source projects in terms of desktop end users. Yet, the same open source philosophies that made these projects so popular are a weak spot that the competition can, and will, use &#8230; <a href="http://www.apreche.net/strict-open-source-policies-lead-to-fail/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Ubuntu and Firefox are two of the biggest open source projects in terms of desktop end users. Yet, the same open source philosophies that made these projects so popular are a weak spot that the competition can, and will, use to get ahead. If they do not change their policies I see Firefox being destroyed by Chrome, and Ubuntu losing ground to Windows 7 and Chrome OS.<span id="more-1148"></span></p>
<p>HTML5 is on the move. Pretty much every browser other than Internet Explorer is supporting it pretty well. However, the codec issue on the video tag is going to be a major headache for Firefox. YouTube, which is really the only video site that matters, has decided to go with H.264. Firefox can&#8217;t include H.264 because of patents, and can only support Ogg Theora. Chrome and Safari do not have this problem. IE will also not have this problem, if and when they get their act together.</p>
<p>This is due to the balance of open source that people like RMS do not understand. If you demand everything be purely open source, you will be missing out on something. The same goes if you demand everything be purely closed source. Some applications only exist closed, and some only exist open. You will have to use both to get an optimal user experience, especially on the desktop. </p>
<p>The overwhelming majority of users do not care about whether something is open or not. They only care that it is free as in beer, and that it has all the features they desire. Regardless of speed benefits, Chrome will beat Firefox because of its willingness to not be 100% pure open source, and include things like the patented H.264 video codec.</p>
<p>For those of you who do not know, Ubuntu has a very strict release cycle. Every six months they release a new version of Ubuntu. The most recent release is 9.10, released in October 2009. It includes version 2.6.31 of the Linux kernel. If there is a bug or security patch to that kernel, Ubuntu will push out an update to the users, such as the current version 2.6.31-17. The thing is, the current version of the Linux kernel is actually 2.6.32.5. Ubuntu 9.10 users will never get version 2.6.32. In order to get a newer version of the kernel, they will have to build it by hand, or wait for Ubuntu 10.4 in April. </p>
<p>What&#8217;s the big deal? The kernel version barely makes a difference in the user experience. Most users will probably not notice or care, even if they are stuck with a very old kernel version. Well, what if you apply the same update policy to something like Firefox? Firefox 3.6 was just released, but Ubuntu users will not get that update. Windows and Mac users will, because Firefox updates itself on those platforms. Ubuntu users will have to wait for Ubuntu 10.4, or jump through hoops to update Firefox by hand. They have to wait 3 months for a very significant user experience update.</p>
<p>The problem with these two open source projects, and others, is not that they are open source. Open source is awesome, and it&#8217;s the only reason these projects can even compete in the first place. The problem is that unlike say, the Apache web server, these target every day users. However, their philosophies and policies do not make the experience of the user their number one priority. </p>
<p>Yes, there are good reasons behind these policies. I support stable software releases and being as open as possible. It&#8217;s simply that the user experience is even more important than either of those. You need to make exceptions to policy when the user is suffering. If a store didn&#8217;t make a reasonable exception to its return policy, you would give it a bad review and maybe even stop shopping there. Why can&#8217;t open source projects also make reasonable exceptions? If they don&#8217;t, they&#8217;ll just slowly lose ground to their competitors.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/strict-open-source-policies-lead-to-fail/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Real Rip-Off in Wireless</title>
		<link>http://www.apreche.net/the-real-rip-off-in-wireless/</link>
		<comments>http://www.apreche.net/the-real-rip-off-in-wireless/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 15:14:49 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Opinion]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1140</guid>
		<description><![CDATA[Verizon and AT&#38;T recently cut prices on their unlimited voice and data plans. Whoop de doo. Text messages are still a rip-off. Data still isn&#8217;t truly unlimited. People seem to really be focusing on these data plan prices. Meanwhile, people &#8230; <a href="http://www.apreche.net/the-real-rip-off-in-wireless/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Verizon and AT&amp;T recently cut prices on their unlimited voice and data plans. Whoop de doo. Text messages are still a rip-off. Data still isn&#8217;t truly unlimited. People seem to really be focusing on these data plan prices. Meanwhile, people are ignoring the voice prices. Let me tell you, that is where the real rip-off is coming from.<span id="more-1140"></span></p>
<p>I remember when I was a kid, and landline phones were still huge. Sprint made a big deal about their ten cents a minute.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/D9bvxqpq_zk&amp;hl=en_US&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/D9bvxqpq_zk&amp;hl=en_US&amp;fs=1&amp;" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p>The number of cents you paid per minute was a huge deal. I remember my grandmother would dial a five digit number before making a long distance call in order to get the price down to five cents per minute. With <a href="http://www.truphone.com/">truphone</a> you can now make many international calls for under three cents per minute. Taking inflation into account, voice calls have gotten ultra cheap over the years.</p>
<p>Now, I&#8217;m someone who doesn&#8217;t talk on the phone much at all. I still need a phone number because it&#8217;s sort of necessary for engaging with society. I also do call family and relatives, and occasionally friends when necessary. But most of my calls are very very short.</p>
<p>So what am I paying for this voice service I hardly use? I have AT&#038;T&#8217;s &#8220;Nation 450 Rollover &#038; 5000 Night/Weekend &#038; Unlimited Mobile-To-Mobile Minutes&#8221; plan. It costs me $39.99 a month. There is no smaller plan available. If you do the math, this comes out to under ten cents per minute. If I&#8217;m paying for just the 450 minutes alone, each minute is under 9 cents. Good deal right?</p>
<p>It would be a good deal if I talked on the phone. As it stands, 4135 rollover minutes available. Oh they&#8217;re so generous letting me rollover the minutes, right? Wrong. The rollover is just an excuse. It makes you feel less bad about paying for all these minutes you never use. The thing is, if you never use them, you&#8217;re paying lots of money for absolutely nothing.</p>
<p>On my last bill I used 20 of the 450 minutes, 4 unlimited M2M minutes, and 64 night &#038; weekend minutes. Even if I were paying a ludicrously high price of 25 cents per minute, for all the minutes, my bill would have been $22. Instead, I&#8217;m paying 45 cents per minute. </p>
<p>The way they structure the plans is highly deceptive. You don&#8217;t think about your voice costs in terms of cents per minute anymore, because you are paying a fixed rate. But when you really think about it, you&#8217;re either paying for something you don&#8217;t use, or you&#8217;re paying way too much for the little that you do use.</p>
<p>Now, for someone who talks on the phone a lot, this probably isn&#8217;t a problem. If I actually used all those minutes, I would actually be getting a pretty good deal. It wouldn&#8217;t be an amazing deal, but certainly not a rip-off. </p>
<p>The other carriers are no better. T-Mobile and Verizon have similar minimum plans of 450-500 minutes for $40. Sprint has a voice plan of 200 minutes for $30. I think somewhere in the fine print there&#8217;s the option to not pre-pay for any minutes, and pay only for the minutes you actually use. Of course, they charge 45 cents for those minutes, making it moot.</p>
<p>There is an argument to be made that wireless minutes should be more expensive than land line minutes. That&#8217;s acceptable, but it&#8217;s not true. Remember, if I used all my minutes, I&#8217;d be paying a reasonable price for them. The problem is that the minimum tier is much too high.</p>
<p>I&#8217;m willing to bet if you looked at the books for any of these wireless companies you would see millions upon millions of dollars paid for unused minutes. I&#8217;m paying as much money for unused minutes as I am for unlimited data, which I use a lot. It&#8217;s about 30% of my phone bill, and I wouldn&#8217;t be surprised if it was 20-30% of their revenues.</p>
<p>Yes, text messages are a rip-off. Yes, data plans are secretly and evilly limited. But most of the money people like me are losing is paying for minutes we never use. Over the course of my two year iPhone contract, I&#8217;ve probably paid over $700 for unused voice minutes. </p>
<p>It&#8217;s nice that we&#8217;re actually seeing a little price war for the unlimited plans. These guys are actually starting to cut some of their ludicrously high margins on the high-end in order to push high-end smart phones to more customers. That&#8217;s well and good, but let&#8217;s also see some competition for the lower end plans. I want to see unlimited data and text for $30-40 with 100 voice minutes for $10-20. Even those prices are a little high, but they are far more reasonable than what I&#8217;m forced to pay now.</p>
<p>Maybe soon I&#8217;ll be able to ditch voice service altogether and use a VOIP solution. Perhaps the reason they don&#8217;t improve their data networks and expand coverage more quickly is to prevent me from doing that very thing.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/the-real-rip-off-in-wireless/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Let&#8217;s Fight Terrorism For Real</title>
		<link>http://www.apreche.net/lets-fight-terrorism-for-real/</link>
		<comments>http://www.apreche.net/lets-fight-terrorism-for-real/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 01:28:00 +0000</pubDate>
		<dc:creator>Apreche</dc:creator>
				<category><![CDATA[Ideas]]></category>

		<guid isPermaLink="false">http://www.apreche.net/?p=1137</guid>
		<description><![CDATA[Maybe you can save lives without getting out of bed. <a href="http://www.apreche.net/lets-fight-terrorism-for-real/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>The dust has largely settled from a failed attempt to detonate explosives aboard a Northwest airlines over the holiday. There were plenty of people talking about what went wrong. That&#8217;s easy, hindsight is 20/20. The thing is very few people are talking about things we can do. The only ideas anyone comes up with are always the same old freedom infringing measures that result in theater, not real security. Well, I have an idea of what we can do, and it can help against a lot more than just terrorism.<span id="more-1137"></span></p>
<p><a href="http://markmaunder.com/2009/crowdsourcing-a-solution-to-air-terrorism/">Mark Maunder suggests</a> we crowdsource the terrorism fight. He&#8217;s on the right track, fundamentally speaking. Our government is clearly incapable of intelligently combating a non-military threat. It must be the citizens themselves who help to stop terrorism. However, Mark&#8217;s specific suggestions are not all that great. None of them would stop a terrorist with a working explosive device. The people were only saved by the stupidity of the terrorist. There was nothing they could have done to save themselves from an intelligent attacker.</p>
<p>And that is the one thing that gives me hope. So many of the terrorists are just complete morons. Terrorism isn&#8217;t really rocket science. Just about any reasonably good engineer could cause massive amounts of destruction. I can personally come up with any number of plans to cause a very large amount of destruction. The reason we are save is because these smart people are smart enough to have jobs, and money, and such. When you&#8217;re smart enough to be a good terrorist, you&#8217;re smart enough not to be a terrorist in the first place.</p>
<p>Despite this, we can not rest easily. Even morons who fail most of the time are dangerous. They did succeed in 2001, in the London underground, in Oklahoma City, and many other times throughout history. They will fail often due to their lack of brains, but they will succeed sometimes, and it is those sometimes we need to prevent.</p>
<p>Start thinking about ways to prevent terrorist attacks. What do you think of? You think of physical defenses. Locking doors, searching people and bags, detecting explosives and weapons, these are all physical defenses. They all try to stop an attack right before, or as, it is about to happen. They also don&#8217;t work. If someone has a bomb at an airport, they can just set it off in the security line. Heck, trains have almost no security whatsoever. As long as you have a situation where there are many people together, it is next to impossible to physically prevent a terrorist attack. Even if everyone is on the lookout, and the crowd reports suspicious activities, that isn&#8217;t going to stop anything.</p>
<p>What you need to do is prevent terrorism way in advance. Intelligence is absolutely the most effective weapon against terrorism. If you know that a terrorist is going to go on a shooting spree tomorrow, you can have police arrest him today. If you know that someone bought a whole bunch of fertilizer, in the winter, and they aren&#8217;t a farmer, and it&#8217;s for a crop that doesn&#8217;t grow in the area, that they are probably up to something.</p>
<p>You might think this information is difficult and expensive to collect, parse, and act upon. You&#8217;re right, it is. But this is exactly where the crowdsourcing comes in. We need to crowdsource the intelligence to pre-empt terrorism. Let ordinary citizens keep a watchful eye about them. Then we can pool, share, and filter to turn the information into intelligence. Then the authorities can use that to pre-empt villainy.</p>
<p>This kind of crowdsourcing can work, but you can already see it&#8217;s a minefield. Untrained citizens are not that great at collecting intelligence. He who has a hammer sees nails everywhere. If you&#8217;re on the lookout for terrorism all the time, suddenly everything looks like terrorism. Is that a homeless guy, or is it a disguise? Is he hiding a bomb in his shopping cart? Is that guy really a utilities worker, or is he putting a bomb in the subway? What&#8217;s that weird device he has? That computer guy&#8217;s screen is weird, is he hacking?</p>
<p>Is there another kind of crowdsourcing we can do that is actually useful, and doesn&#8217;t require as much training? I think there is. We can find terrorists while sitting on our asses, on the Internet. For real.</p>
<p>I assume people reading this are fairly technologically competent. If you wanted to get illegal things online, like pirated media, guns, drugs, child porn, etc. do you think you could do it? It&#8217;s quite trivial. Yet, law enforcement agencies can&#8217;t seem to figure it out. If my only job was to find illegal activity on the Internet, I could have people arrested faster than they could be processed.</p>
<p>Do terrorists use the Internet just like pirates and pedophiles? You bet they do! Our recent terrorist Mutallab <a href="http://www.msnbc.msn.com/id/34618228/ns/us_news-washington_post">posted all over the Internet</a>. He wasn&#8217;t particularly secretive either. He openly displayed his unhappiness and fundamentalist beliefs. It was a textbook case of a terrorist to be, right out in the open where anyone could see it. The same sort of thing goes not just for terrorists, but school shootings, and other criminals. A great many of these people posted their craziness all over the web before they acted.</p>
<p>These terrorists are not ultra smart super villains like Doctor Doom. They&#8217;re mostly just really sad individuals who reach the breaking point. They post their plans openly. They&#8217;re not hatching an evil scheme in secret, they&#8217;re crying for help. By searching Google, newsgroups, IRC, and Facebook we can find the next Mutallab or <a href="http://en.wikipedia.org/wiki/Seung-Hui_Cho">Seung-Hui Cho</a> before they strike. The authorities can&#8217;t even figure out BitTorrent, but we can. We can find these sad people on the &#8216;net and then do something to make sure they never fall so far as to actually try something.</p>
<p>You&#8217;re probably sitting at your computer right now, and you&#8217;ve had enough free time to read this blog post. You probably also have enough free time to do some searching. Go out there, and see if you can find people on the web who are actually likely to be real terrorists in the making. Maybe you can save lives without getting out of bed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.apreche.net/lets-fight-terrorism-for-real/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
