Fixing the problem with rel=’next’ and Yoast

Since I moved this blog across domains, I have been using the WordPress SEO by Yoast plugin instead of the infamous All In One SEO Pack plugin I previously used. So far I’ve been happy with it and it is pretty neat.

However, today I noticed an unfamiliar line of code when looking at the source of this page. On the homepage the Yoast plugin had created a <link rel=”next”> tag:

<link rel="next" href="http://guidovanoorschot.nl/page/2/">

I wasn’t familiar with the rel=’next’ attribute, so I found some details in the HTML specification here. Looking at the code again, I also found that the canonical URL of this page was the same as the URL:

<link rel="canonical" href="http://guidovanoorschot.nl/page/2">

At first I thought this would be a problem as Google might regard the content on this page 2, which was the same as individual posts, as a duplicate. However the plugin also added the following line: <meta name="robots" content="noindex,follow"/>, which solves that problem by not allowing Google to index that page.

Fixing the rel=”next” problem in Yoast

However, I found that for some people with different themes the rel=’next’ was zausing problems. If this is the case, you can fix the problem by commenting out one line in the plugin. Go to line 241 in wp-content/plugins/wordpress-seo/frontend/class-frontend.php and comment it out:

$this->adjacent_rel_links();

to

//$this->adjacent_rel_links();

This way the link won’t show up anymore in your homepage’s code. Do keep in mind that when upgrading the plugin you should check to make sure it doesn’t pop up again.

How to fix Spotlight when it keeps indexing in Mac OS X Lion

Today I noticed that the fan of my MacBook was continuously spinning because my Spotlight kept indexing for hours. Even when it was finished, a couple moments later it started reindexing again. After searching Google for a while finding no working solutions, I finally found one that worked for me.

Spotlight keeps indexing – the fix

If you execute the following command in your Terminal (Applications/Utilities) Spotlight should stop indexing (N.B. make sure you copy it exactly):

sudo rm -rf /.Spotlight-V100/*

Re-index Spotlight

The above command deletes your current corrupted index. Now execute the following command to force a re-index of Spotlight for one-time(If it gives you a -400 error, rebooting and trying again should work). After running the command, Spotlight should start re-indexing within a minute.

sudo mdutil -i on -E /

This is not a permanent solution, as the problem happened to me twice in the last eight months. So if your Spotlight keeps indexing too, please do let me know it it worked for you, and if you have any other solutions or know the root cause of this problem.

How To Make Sure Your Heroku App Doesn’t Shut Down

I am working with Heroku lately and am really enjoying the ease of deploying a Django application with it. However, as I am in early development of my app, I don’t really have visitors yet. I noticed that I would take very long to load my website for the first time, while it was fast after that first request. I did some reading and understand that Heroku ‘shuts down’ your server when there is a period of inactivity, when your site doesn’t get visited for a while.

I thought this was rather annoying and definitely not desirable when you try to gain initial visitors — nobody likes to wait ten seconds for a page to load. In this post I’ll show you how I made a workaround that will keep the server alive.

Using Cron and a little Python script

First make a simple python script (e.g. acces_page.py) that loads a URL:

#!/usr/bin/env python
import urllib2
if __name__ == '__main__':
    f = urllib2.urlopen('http://myapp.herokuapp.com')
    print f.read(10)

Then upload it somewhere on your second – not heroku – server and put it in some folder (e.g. /your/folder/). Then add the following line to your crontab by doing the crontab -e  command.

*/5 * * * * ~/your/folder/access_page.py > $HOME/cron.log 2>&1

This will run the python script every five minutes, accessing the webpage defined in your python script. To test if it works it will output the first 10 characters of the webpage in the file cron.log in your $HOME directory. When you see it’s working, you can remove the > $HOME/cron.log 2>&1 part.

If the log file says something like access denied, chmod your access_page.py file with chmod +x access_page.py.

An Apriori Algorithm Analysis Of Steve Jobs’ Tribute Messages

Yesterday, Neil Kodner wrote an interesting post in which he scraped and analysed the tribute messages for Steve Jobs on the Apple website. Some interesting insights were, for example, that people talked about the Mac and iPhone the most, and compared Steve Jobs with great minds like Einstein, Ford and Edison. Also, Neil found that ‘rest in peace’ was the most used trigram in all the messages.

Seeing this, it made me think of applying the apriori algorithm, which I recently implemented for my Web Text Mining class, to the tribute messages. The apriori algorithm explained according to wikipedia:

In computer science and data mining, Apriori is a classic algorithm for learning association rules. As is common in association rule mining, given a set of itemsets, the algorithm attempts to find subsets which are common to at least a minimum number C of the itemsets.

The way me and my group-mate Rene Dekker implemented it, the algorithm extracts association rules for words from a sentence or document (stopwords, punctuation and numbers are removed from analysis). So, I took the text file with tribute messages and applied the algorithm to see what word combinations are used frequently within one tribute message. I’ll get into the algorithm in a later blogpost, but here are the results for a minimum support level of 1% and minimum confidence level of 85%.

Interpreting the results

Jobs, friends, condolences -> family

This means that the four words ‘Jobs’, ‘friends’, ‘condolences’, & ‘family’ together (but not necessarily next to each other) occur in at least 1% of the tribute messages. Also, when ‘Jobs’, ‘friends’, & ‘condolences’ occur, at least 85% of the times the word ‘family’ is also present in the message.

friends, Steve -> family
Peace, Jobs -> Steve
Thank, Jobs, us -> Steve
world, friends, condolences -> family
Mr, world -> Jobs
Jobs, computers -> Steve
know, friends -> family
friends, many -> family
Mr, friends -> family
friends -> family
iPad, Jobs, Apple -> Steve
Jobs, created -> Steve
condolences, friends -> family
Mr, friends -> Jobs
friends, lost -> family
go, friends -> family
friends, Apple -> family
never, friends, Steve -> family
people, Jobs, world -> Steve
friends, like -> family
life, friends, Steve -> family
Jobs, friends, condolences -> family
friends, thoughts -> family
friends, always -> family
never, Mr -> Jobs
friends, Steves -> family
friends, Apple, condolences -> family
world, friends, Steve -> family
friends, man -> family
condolences, Steves -> family
Jobs, life, great -> Steve
prayers, friends -> family
Jobs, world, changed -> Steve
human, Jobs -> Steve
friends, Apple, Steve -> family
brought, Jobs -> Steve
friends, condolences, Steve -> family
friends, condolences -> family
friends, us -> family

I’ll elaborate more on the algorithm and different improvements in efficiency and usefulness we made in a later blogpost — please stay tuned.

My Appsterdam Hackathon Experience

Last week I spent three days at the Appsterdam’s Open Data Hackathon on Picnic Festival. The local government of Amsterdam had made different data sources publicly available and created a contest for building apps on top of that data.

As I arrived solo, I luckily found some great teammates to work together with (@danielsteginga, @jjeekkoo & @devoorzitter). After a small brainstorm session we decided on our product and divided the workload. We wanted to do something with the data of public art in Amsterdam and decided to build an app with which you could find the art near you, learn about it, and discuss it with fellow community members.

Then, over the course of three days we hacked together the neat little app LocART. Unfortunately, we didn’t win the contest, but I learned some great lessons along the way.

Design is important

Even though we didn’t win the competition, we did get a honorable mention for best design. Also, several other people that saw the app, explicitly mentioned they really liked the design. I had the feeling that gave us some immediate likability that we wouldn’t have gotten otherwise.

I personally notice the same in my thinking when I see the design of new startups — it is often the design that gives some initial likability or perceived professionality.

Be able to relax when others do things differently

Over the course of the hackathon I noticed that sometimes one of my teammates would do something differently than I would have done, codewise or something else. Instead of trying to show why ‘my’ way would be better, it was great and humbling to learn from seeing people do things in other ways.

Developers are wanted

At different occasions during the hackathon, people would come by looking for developers for their ideas. One guy approached us and asked if we were able to develop his idea. When we asked what his idea was he basically described an application like group.me or WhatsApp. We politely inquired what the added value over these existing apps was, after which he said: “there is something extra, but it’s a secret. I’ll tell you when you start working for me”. After that it went on and on, but I think you get the gist of it.

Having read numerous anecdotes on hacker news about annoying business guys with ideas looking for developers, I could only be amused by all this and politely explained to him why this approach would never work after which I gave him some pointers on finding technical employees/founders and what not to do.

You can do awesome things in a short timespan with great people

I am genuinely impressed of how fast we got something to work and look pretty neat. In just three days we designed a logo, the layout and the workflow. We set up our database and imported and cleaned our data. We build an api on top of our database and went through the jQuery Mobile documentation. We created the front end and integrated all of this in just three days with a working app as result. I mean, that’s a lot of work done and a lot of things I learned from that.

Even though we didn’t quite finish the app fully, a basic version is already working — check it out on your mobile phone at m.locart.nl.

For those of you not on a mobile device, here are some pics (or check locart.nl):

Setting up my Python development environment on Mac OS X Lion

As I just purchased a new MacBook Air, I wanted to make a clean python development and start using virtualenv. This post shows how I set up my new python development. The system came with Python 2.7 which is what I’ve been using and wanted to keep using — so no need to install another Python version.

First install pip using easy_install.
For some python modules you need the gcc libraries. You can get those by downloading Xcode which has them all included. However, Xcode will take up gigabytes of disk space. So if you don’t plan on using Xcode you can use the OSX GCC installer made by kenne threitz — this is only around 300 MB. After you have installed this, you can for example install ‘pil’ without getting errors.

Next, I installed virtualenv to be able to create different virtual environments to keep my different projects easily seperated.
And after doing this I immediately installed virtualenvwrapper to make it easier to use virtualenv.
To make sure we you can use the virtualenvwrapper commands edit your .bash_profile file. Type: ‘vim .bash_profile’ in your main dir and put in the following (change yourprogrammingdir to the directory of your projects):

export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/yourprogrammingdir
source /usr/local/bin/virtualenvwrapper.sh

Save it and source your .bash_profile by: ‘source .bash_profile’.

For now this is what my python development looks like, I’ll update this whenever I add things to it.

MacBook Air 13″ vs MacBook Pro 13″: Why I Bought The Air

A couple of weeks ago, Apple upgraded their MacBook Air line; the Air too is now equipped with an i5 processor, just like its bigger Pro brother. As my current MacBook is turning three years old this month, I thought about getting a new one. For me, there were only two models between which I needed to choose. I want a 13″ sized laptop and no expensive upgrades; so either the basic MacBook Air 13″ ($1299) or the MacBook Pro 13″ ($1199).

Macbook Pro 13-inch vs MacBook Air 13-inch

With the latest upgrade the technical differences between both models are smaller than ever.

Macbook Pro’s advantages

  • Faster i5 processor (2.3 GHz vs 1.7 GHz)
  • Bigger hard disk (500GB vs 128GB)
  • HD webcam built in (Air just has SD)
  • Has optical drive, ethernet, and FireWire port (Air doesn’t)

MacBook Air’s advantages

  • Lighter (2.96lbs vs 4.5 lbs)
  • Thinner
  • Higher resolution (1440×900 vs 1280×800)
  • Faster hard disk (SSD vs HDD)
  • No glare screen

My considerations

Some of the differences between the two I don’t care about. I never use FireWire and haven’t used both my ethernet port and optical drive for the last two years. Also I don’t really care about the different webcams as the SD one in my current MacBook has always performed just fine for Skype-usage.

So then it’s down to the difference in processor speed and bigger hard disk (in favor of the Pro) and resolution, size, weight and faster hard disk (in favor of the Air).

Subsequently, I tried to find information on the difference in performance between both models. A lot of websites just bluntly state that the Pro is faster because its processor’s clock speed is 0.6 GHz higher. However, Macworld did some benchmarks and showed that for a lot of tasks the MacBook Air 13″ actually performs much better than the MacBook Pro 13″ because of its faster, SSD hard disk.

Why I bought the Air

The choice thus basically comes down to: Do I want a MacBook Pro with a bigger harddrive or a much lighter, smaller MacBook Air with a better resolution and often better performance. Boiling it down to this, making a choice was pretty easy. To me, the $100 difference in prize is well-worth the increased portability, higher resolution and better performance of the MacBook Air.

How To Change User Profiles In Firefox On Mac OS X

As was working on developing a Firefox extension, I wanted to make a special user profile for development in Firefox. Many tutorials advise you to type the following into terminal to get in the user profile screen.

/Applications/Firefox.app/Contents/MacOS/firefox-bin –profilemanager

However, that wasn’t working for me. I couldn’t easily find a fix for it on Google, so here is an overview of other methods to get into the user profile settings for different Mac OS X versions (source), hope it can help some fellow Googlers.

On Mac OS Snow Leopard (10.6) and newer, type this in the terminal:

/Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev &

On Mac OS Leopard (10.5) and older, type this in the terminal (on one line):

arch -arch i386 /Applications/Firefox.app/Contents/MacOS/firefox-bin -no-remote -P dev &

The last one worked for me. So if you are having problems with switching between users in Firefox on Mac OS X, try the code above. Let me know, if you got it to work!

My First Time With A Social Game: A Painful Experience

Not a day seems to go by without any news on record amounts of users, big acquisitions and huge revenue numbers in the social gaming industry. PlayFish got bought by EA last year in a $400 million deal, Zynga filed for IPO to raise as much as $1 billion and in Asia, Nexon is expected to break the $1 billion revenue number this year with huge profit margins.

As much as I hate all the annoying FarmVille requests, I try to keep as far away from the social games these companies develop on Facebook. I always wondered though how these companies are making all this money. Why would anyone pay for in game currency, virtual goods and other useless junk.

Enter CivWorld…

So when I read that CivWorld was introduced to Facebook, I knew I had a hard choice to make. I have always enjoyed Civilization and spent hours getting my economy up, working my way through the tech-tree and building my empire. After days of contemplation, I decided to give CivWorld – and social gaming on FaceBook – a try.

My First Time

There I was, being greeted and welcomed into a colorful world. At first I didn’t know what to do, but the smart UX designers at Firaxis took me by the hand and gave me a series of quests to complete. I built a house, a garden, recruited some scientists and produced some defensive infantry to protect my city. As I saw my city grew and got rewarded for fulfilling straightforward quests, I started to get into the game. Then, the game introduced the concept of mazes.

The Maze

The maze is a minigame within CivWorld and its goal is to move the green dot through the maze to the center. Once there, you get extra science points and in this way unlock different technologies faster. The challenge lies within the fact that you only have a certain amount of moves that you can make in order to get to the middle.

Screenshot of the Maze minigame

So, having carefully built up my empire, I now needed to find my way through the maze. The first one was pretty easy and I immediately got an extra boost in my tech. The second maze, however, was already a bit more difficult. As I kept trying to find my way through, the amount of moves I could make kept decreasing. Finally, when I had zero moves left, I was stuck.

Not knowing what to do at first, I luckily discovered the ‘get 5 moves’ button. By pressing this button, I got to make 5 extra moves in exchange for what appeared to be some sort of bills. In my quest for extra science points, I eagerly pressed this button again and again.

Suddenly, the page seemed to be redirected to a different page. As I was exited to see what was to come, I waited in anticipation for the page to load. Who knew what cool tech I could be getting?!

Then, after waiting for a while, the page finally finished loading and the following screen appeared:


There it was… I couldn’t believe what had just happened. At one moment, I was having fun playing my CivWorld game, then, in a flash, I got interrupted brutally and was being asked for money.

The first time always hurts

The worst thing however wasn’t me being interrupted. The worst thing about it was that, after 15 minutes of playing, I almost wanted to pay for the extra CivBucks. Having my reservations going into this game, I couldn’t believe how addictive it was and how good it was in convincing me of the ‘extra value’ of in-game currency.

I too, fell for it.

As bad as I felt, there is one thing I learned from this experience though. I get it now. The press releases boosting millions of users, the news articles, the revenues and the profits… all of it.

Moving on

Preventing myself from wasting hours of my life and risking a possible bankruptcy, there is only one thing I could do:

Goodbye citizens, goodbye CivWorld, goodbye social gaming… I’ve got some programming to do!

 

Python vs Java In CS Classes: A Comparison

As I work my way through Learn Python The Hard Way, exercise 12, which elaborates on how to get user input from the command line, made me reminisce on my time programming in Java. In my Java programs I would have used the following code to get the user input from the command line and store it in variable ‘age’:

import java.util.Scanner;

public class Question {
    public static void main(String[] args) {
        System.out.print("How old are you? ");
        Scanner question = new Scanner(System.in);
        int age = question.nextInt();
    }
}

And this is how I do the same in Python:

age = raw_input("How old are you? ")

Please note that my Java is rusty and there is probably a shorter way to do the same, but look at the difference!

As I understand it, more and more universities are using Python in their Introductory Computer Sciences classes. Even though I had fun in my Programming in Java class, I think this is a good development. Python provides an easier first experience into the world of programming and is less intimidating at first sight for new students.

Personally, I find it a big relief not having to work with the ugly Java-syntax and being able to focus on writing awesome code instead of searching for missing semi-colons and curly brackets. Off course there will always be the need for Java, C, or other languages that are much faster, but for introductory purposes, I would be happy to see Python used in the classrooms more often!