Ramblings Of a Madman

Yeah, like i would know a good description…

Two awesome sports in one day

It’s not every day that you find out about great people in awesome sports.

First, this guy puts Robin Hood and Legolas to shame with his archery skills. A lot of interesting things about his technique which, once again, comes to show that Hollywood distorts reality like crazy: 

Second, there are Long Sword fights. For real. Enough said:

Avoiding SSL redirect loop

If you are configuring an nginx website to use SSL and - by any chance - you need to setup more than one “server” entry (for instance to make www redirect to the plain URL), keep in mind that you need to declare the ssl certificate mumbo-jumbo in both entries, otherwise browsers will enter a redirect loop.

Something like the following will do:

server {
        listen 443 ssl;
        server_name www.zenblast.com;

        include zenblast-ssl.conf;

        return 301 $scheme://zenblast.com$request_uri;

server {
        server_name zenblast.com;
        listen              443 ssl;

        include zenblast-ssl.conf;


zenblast-ssl.conf is where we define stuff like ssl_certificate, ssl_certificate_key, ssl on, ssl_ciphers, ssl_prefer_server_ciphers on, and ssl_protocols. Notice that the file is included in both entries.

Hope this helps save someone 30 minutes of Googling :)

Tell me what to do, i'll tell you who i am

We can't all be strong.

In any group where everyone is different, some are stronger and some are weaker. There is a hierarchy of power (no matter what the specific kind is). And every single individual wants to satisfy his own wish of being stronger than his neighbors.

Now, if you are weak, it's in your best interest to attach yourself to stronger individuals. Because in the end, if they win, you win[^stab]. So you, as a weaker entity, look for leadership in this stronger individual. You will not be his equal, but at least you will be better than other individuals who are stronger than yourself. But the stronger individual also benefits from being in a group. Because then he can take on more than one single individual who might be almost as strong as he his. If he doesn't do this, there is a chance that a couple of slightly-less-stronger than himself will gang up on him.

[^stab]: Especially if you stab them in the back after you've won :)

The point here is: everyone wants to be in a group, for one reason or another. And if you are in a group, chances are you do as the group does, no questions asked. Because you don't want to be left out.

This leads to a very interesting question: Do people like to be told what to do?

Let's consider this: We have been part of some group or another basically forever. And, if you are in a group, you tend to do as the people of that group do. Multiply this by endless centuries of doing the same thing and - all of the sudden - you have individuals that don't do any thinking at all. The leaders do that for them. That does not mean they like it. It just means that they are so used to it that it's easier to follow orders than to question them, simply because that's what you've been doing all this time.

And that - i believe - explains things like organized religion, eating fast food every day, or dictatorships. We do these things because other people tell us to do it, be it by ways of tradition, advertising and media[^media], or plain word of mouth. We are so formatted to group thinking that most of the time we don't question these things.

[^media]: Look into how much money brands put into advertising these days and get ready to have you mind blown. As a bonus, look at a few ads and see how many are implicitly getting you into group thinking mode.

So do people like to be told what to do? I don't think so. But it sure is easy, don't you agree?

Fast blogging setup

## Static vs Dynamic

I've maintained my own website/blog for as long as i can remember. Ever since the days of static HTML pages, simple PHP scripts, [Wordpress](http://wordpress.org) installations, [Joomla](http://www.joomla.org), [Drupal](https://www.drupal.org), [Postnuke](http://www.postnuke.com), [PHPNuke](https://www.phpnuke.org), you name it, i've tried it.

So one day i found out about static site generators. The basic idea is that, instead of having some kind of storage for the content (database), it lives in plain files. The webpages are generated by an engine and can then be served as plain HTML which is - obviously - much faster than any interpreted system (like PHP, Rails, ).

Here's an example of dynamic page generation like - for instance - a Wordpress installation, or a Ruby on Rails website:

The biggest problem with this is speed. Since there are so many steps, it can never be as efficient as static HTML pages. Of course you can always cache the requests and make it a bit faster, but i tend to like the path of least resistance :)

Here's the static generation approach:

The website pages are generated once and served statically, which is much faster.

Before i proceed to explain how i've implemented it, let me just say that there are many advantages for a full fledged dynamic website (e-commerce, storing user information, registrations, etc, etc.). But if your only concern is to publish content on the web and allowing readers to comment on it you can easily pull it off with this system, integrating it with something like [Disqus](https://disqus.com/websites/), for comments.

## Practical example

To implement this system we need:

- **A static website generator**. I chose [Middleman](http://middlemanapp.com/). Others include [Jekyll](http://jekyllrb.com/), [Hugo](http://hugo.spf13.com/, [Pelican](http://blog.getpelican.com/), [Hexo](http://hexo.io/) and [DocPad](http://docpad.org/). - **Some way to transfer the generated files to your server**. [Rsync](http://en.wikipedia.org/wiki/Rsync) is my choice, but you can pull it off in a gazillion ways, including [Dropbox](https://www.dropbox.com) synchronization, for example, or just FTP. - **A web host running a webserver**. In my case i have a [Linode](http://www.linode.com/) with an [Ubuntu](http://www.ubuntu.com) installation that has [Nginx](http://www.nginx.org/) running. Other solutions might include a combination of [Apache](http://httpd.apache.org/), [Dreamhost](http://www.dreamhost.com/), [HTTP Explorer](http://http-explorer.sourceforge.net/), [Bluehost](http://www.bluehost.com/), [LightHTTPD](http://www.lighttpd.net/) and [A Small Orange](http://www.asmallorange.com/)

### Step 1 : Install Middleman

There are plenty of guides on how to install this out there, so i'll just point you to the [getting started guide](http://middlemanapp.com/basics/getting-started/).

### Step 2 : Create your pages

Middleman has a bunch of templates that you can use as a starting point, so check out their fantastic documentation and make it happen. In alternative you can proceed with the example template you should have ended up with if you followed their tutorial.

### Step 3 : Middleman commands to know

Here are the commands you are most likely to use with middleman, and their explanation:

**Start the development server**, so you can test your site at `http://localhost:4567`:


**Generate a new blog post**, assuming you installed and set up the [middleman-blog plugin](http://middlemanapp.com/basics/blogging/):

middleman article "title of your new post"

**Build the static pages for deployment**:

middleman build

**Deploy your pages using middleman**:

middleman deploy

### Step 4 : Deploy

You don't necessarily need to use the `middleman deploy` command if you don't want to. After you do `middleman build` all your generated content can be found inside the `build` folder on your project root. Deploying it is simply a matter of getting those files into your webserver. And for that you can use any method you prefer.

I like to let my server do all the work of building and deploying by using the following workflow:

- I write a post or modify a page - I call a script on my local computer that does the following:

#!/bin/sh rsync -h -r --delete /data/static-blog/source/* void@blog:/home/void/static-blog/source ssh void@blog "touch /home/void/static-blog/.build"

First, it copies all of my site's sources into the working folder on the server (this is the step where you could use dropbox, btw). Then it creates a file on that folder (`.build`) that instructs the server to build and deploy the website automatically.

- The server has a cron job running every X minutes that executes a script:

*/5 * * * * /home/void/bin/build_blog.sh

And the contents of that script are:

#!/bin/bash if [ -e "/home/void/static-blog/.build" ] then logger -s "Blog: Starting build..." logger -s "Blog: Sourcing RVM..." source /home/void/.rvm/environments/ruby-2.0.0-p0 logger -s "Blog: Removing order file..." rm /home/void/static-blog/.build logger -s "Blog: Getting into folder..." cd /home/void/static-blog logger -s "Blog: Executing bundle install..." /home/void/.rvm/gems/ruby-2.0.0-p0/bin/bundle install logger -s "Blog: Building files..." /home/void/.rvm/gems/ruby-2.0.0-p0/bin/middleman build logger -s "Blog: Copying files into place..." rsync -h -r --delete build/* /data/static-blog/live/ logger -s "Blog: Build done." fi

Simply put, the script checks for the existence of the `.build` file inside the working folder and - if so - sets up the environment for bundle, generates the website, and moves the generated files in the `build` folder into the nginx folder i have setup in `/data`. It also removes the trigger `.build` file so the process isn't restarted on the next cron execution.

## Conclusion and future work

I think this is an overall nice setup. Things i would like to improve include not having to trigger the build process. Ideally any change to the blog folder on my laptop should automatically build and deploy the website. Reasons why i haven't been able to do it:

- Dropbox doesn't seem to trigger file changes for [incron](http://inotify.aiken.cz/?section=incron&page=about&lang=en) (a file system watch service), which sucks. - [inotify](http://inotify.aiken.cz) is an alternative to incron, but unfortunately i've ran into another problem: Changes in files inside the working folder trigger multiple alarms (sometimes more than one per changed file). This means i have no way of knowing if the file syncronization has ended (either by dropbox or rsync) and wether i can start the build process or not. Otherwise i risk building with only half the files in place and that might break the site.

If you have any ideas on how to make the process more efficient [please share](http://twitter.com/nocivus); i would love to hear all about it.

Consciousness found?

This [article](http://www.sciencedaily.com/releases/2014/01/140116085105.htm) explains how scientists found quantum vibrations inside brain neurons, the reason we are sentient beings.

The now supported theory, called **"orchestrated objective reduction"**, apparently *"(...) opens a potential Pandora's Box, but (our) theory accommodates both these views, suggesting consciousness derives from quantum vibrations in microtubules, protein polymers inside brain neurons, which both govern neuronal and synaptic function, and connect brain processes to self-organizing processes in the fine scale, 'proto-conscious' quantum structure of reality."*

The lost me at "Pandora" :)

'Fish Shell 2.1 messed up prompt'

If you upgraded to the [Fish Shell](http://fishshell.com) version 2.1 you might have noticed your prompt now containing a bunch of new lines (blank). I believe it's due to the fact that the **echo** command now produces a new line by default (even though that's not explicitly stated in the [release notes](http://fishshell.com/release_notes.html)) [1](#note).

To solve it, replace all ocurrences of echo in your Fish prompt function with **echo -n \**. This will tell echo to not end with a new line.

Happy Fish'ing ;)

1. Fish developers, correct me if i'm wrong please :)

'Google Drive new document bookmark'

Here's a neat trick: Bookmarks to create all sorts of Google Drive documents. This way you don't have to first access Google Drive and click on new, you can just have the appropriate bookmarks in your browser's toolbar. Just add these links:

- New Google Document: [https://drive.google.com/document/?action=new](https://drive.google.com/document/?action=new) - New Google Spreadsheet: [https://drive.google.com/spreadsheet/?action=new](https://drive.google.com/spreadsheet/?action=new) - New Google Presentation: [https://drive.google.com/presentation/?action=new](https://drive.google.com/presentation/?action=new)

Have fun documenting :)

'You should get Training Time for iOS'

And why, you might ask? For one because i made it :)

But seriously, if you are into intense, repetition-based training, you might want to take a look at it. It's an [iOS app](https://itunes.apple.com/us/app/training-time!/id692787267?mt=8) that allows you to set the duration of each repetition, as well as the resting time between reps. Then all you have to do is hit start and listen to the app as it tells you when to rest and when to exercise.

Because i rarely develop something i don't want for myself, i've been using it for a while, along with a set of 5-6 different exercices, for a total of 7-8 minutes of training everyday and i've found it to be a nice and fast way to be in good general shape. Your mileage may vary but you can always top that with, who knows, a bit of [Kung Fu](https://en.wikipedia.org/wiki/Wong_Shun_Leung) ;)

Training Time! can be found on the App Store, [here](https://itunes.apple.com/us/app/training-time!/id692787267?mt=8).