Easy trick to reduce spam in WordPress

 Jan 4th, 2015 

 , , ,

Last year I neglected this blog and after a while I discovered that it wasn’t working well anymore. Requests would time out, the admin panel was loading slow and the experience sucked even with caching enabled. After doing some investigation, I found out that comment spam was the culprit. There were thousands of spam comments every month and many more attempts that were hitting the server really bad. The chart below shows that at the peak there were more that 125K comments per months that Akismet was catching. I had ReCaptcha enabled but it looks like there is a way to bypass it since the comments were ending up in the database.

Before and after the spam block trick
Before and after the spam block trick

So, how did I get from 128K spam comments to just 80/month?

Read the rest of this post »

The books I read in 2014

 Dec 26th, 2014 


2014 is almost over, which means it is the time for me to share the books I read this year. The plan was to read 1 book per month but I only managed to read 10 books. Here they are:

Read the rest of this post »

Plant soil moisture and light monitor

 Dec 4th, 2014 

 , , , , ,

In this tutorial I am going to show you how to create a soil moisture and light monitor for your plants using an Arduino. You can use it to keep track of when your plants need water and light. I’m also going to show you how to collect the data on a Raspberry Pi and display it on an LCD.


Read the rest of this post »

Raspberry Pi sync date and time

 Nov 22nd, 2014 


The Raspberry Pi does not have a RTC (Real Time Clock) module and it is not able to keep the date and time without a power source. If your Raspberry Pi is not connected to the Internet, you are out of luck and the only option is to buy and install an RTC module. However, if it has Internet, you can make it sync the date and time from a time-server.


Follow these steps to set the time servers and the time zone:

Read the rest of this post »

SerialProtocol – let the devices talk

 Nov 13th, 2014 

 , , , ,

SerialProtocol is a software protocol for sending structured data via serial between two Arduino, two Raspberry Pi, or an Arduino and a Raspberry Pi.

Sending data through serial is trivial both on Arduino and Raspberry Pi. On Arduino, you can use the Serial class and on Raspberry Pi you can use, termios or an other library. The problem is how to send structured data that can be understood by both the sender and receiver.

For the purpose of this blog post I am going to use the following data structure:

struct MyMessage
    uint8_t MessageId;
    uint8_t Value;

It represents a message with an identifier and a value corresponding to that message. You can imagine this as being the data sent by sensors from Arduino. For example, the message with ID 100 is the value sent by a temperature sensor and the message with ID 101 is from an accelerometer.
Read the rest of this post »

Is Amazon Kindle Unlimited worth it?

 Jul 18th, 2014 

 , , , , , ,

Amazon announced Kindle Unlimited, a new service that gives unlimited access to 600.000 books for $9.99/month.

The number sounds impressive, but even reading 1% of those books is close to a utopia. Underestimating and assuming that reading a book takes 1 day, reading 6.000 will take about 16 years. Moreover, so many choices can lead to SADD (Streaming Attention Deficit Disorder) – instead of reading a book from beginning to end, the reader gives up part way up and picks a new one, hoping to find something more exciting. This is a behavior observed only when the cost of change is less than the expected gain. In this case the cost is 0 (if you exclude the monthly fee) so surfing from book to book is extremely easy.

However, I’ve got excited while reading about the new service because it might help me save some money. Therefore, I’ve decided to do some math and figure out if this service is a good deal for me.

Read the rest of this post »

Bose QC15 vs Audio-Technica ATH-ANC7b

 Apr 12th, 2014 

 , ,

We recently moved in a new building that has open offices. It get pretty loud sometimes with ~10 people in the same room. I wanted something that can isolate me from the noise and since I don’t like ear plugs, I decided on noise cancellation headphones. After reading some reviews I tried Bose QuietComfort 15 and Audio-Technica ATH-ANC7b.


Construction and case

Both headphones are well-built. However, ATH-ANC7b is made of better quality materials; it is sturdier and I bet it could take greater damage than Bose before breaking. Both sets have leather ear cups but the Bose ones are softer and more comfortable.

In terms of case, again the ATH-ANC7b case seems stronger; it is a rectangular case with rounded corners, nothing fancy. The Bose case has the shape of the headphones but I think that makes it less resistant to damage (more concave surfaces). Both cases have enough room to store an MP3 player, cables and extra batteries.

IMG_2101 IMG_2108 IMG_2106

Noise cancellation

This is the primary reason I got these headphones. Both of them need one AAA battery to cancel noise.

When enabled, the noise cancellation on ATH-ANC7b is pretty good. You can still hear human voices but it is able to cancel most of the background noise. The noise cancellation on Bose is… unbelievable. Enable it and you are locked in a bubble. No more noises, no nothing. It is actually scary how quite it gets – if you wear them without listening to music, you can hear the blood in your ears. But, just like ATH-ANC7b, you can still hear voices and non-background noise.


I didn’t get these headphones for sound quality. Both, do a pretty good job at playing music with noise cancellation on. With noise cancellation off, Bose cannot play any sounds. It is astounding that such expensive headphones cannot be used as just headphones. That’s a very big minus for Bose.
Read the rest of this post »

Advanced bindings with the Windows Azure Web Jobs SDK

 Jan 27th, 2014 


The Windows Azure Web Jobs SDK is a framework that simplifies the task of adding background processing to web sites. You can get more details about it by reading the Getting Started guide or Scott Hanselman’s introduction. Scott describes the Web Jobs SDK very well: “minimal ceremony for maximum results”. The Windows Azure Web Jobs SDK (codename SimpleBatch) is a very simple framework but provides some powerful binding capabilities.

The most simple advanced binding is the blob name placeholder. It allows you to express the intent of listening to blobs in a specific container that match a specific pattern. For example, you are only interested in blobs that end with “.jpeg”, or only blobs that are prefixed with “input-” and have the extension “.txt”, or you just want the name of the blob and you do not want to bind to an Azure SDK type.

public static void Thumbnails(
    [BlobInput("images/{name}.jpeg")] Stream inputImage,
    [BlobOutput("thumbnails/{name}.jpeg")] Stream outputImage)
    // Code that reads the image from inputImage and writes it to outputImage

The function above will only be triggered by blobs in the “images” container that have the extension “.jpeg”. The value of {name} placeholder from the input will replace the {name} placeholder in the output. For example, if the input blob is “images/img123.jpeg” then {name} is “img123″ and the output image is “thumbnails/img123.jpg”.

The name placeholders can be also be used to read and write to and from the same container without triggering an infinite loop (the output retriggers the function).

public static void Thumbnails(
    [BlobInput("images/full_{name}.jpeg")] Stream inputImage,
    [BlobOutput("images/thumb_{name}.jpeg")] Stream outputImage)
    // Code that reads the image from inputImage and writes it to outputImage

The function above reads from the “images” container and writes back in the same container. However, it is only triggered by blobs suffixed with “_full.jpeg” and writes blobs that end with “_thumb.jpeg”. For example, if the input blob is “images/full_img123.jpeg”, then {name} is “img123″ and the output image is “images/thumb_img123.jpeg”.

The placeholder binding is not limited to blob output only. If you need the value of {name} in the code, you can get it by adding a parameter named “name” to your function.

public static void Thumbnails(
    [BlobInput("images/{name}_full.jpeg")] Stream inputImage,
    string name,
    [BlobOutput("images/{name}_thumb.jpeg")] Stream outputImage)
    // Code that reads the image from inputImage and writes it to outputImage

When the function above executes, the parameter “name” will have the value of the {name} placeholder. For example: if the input is “images/img123_full.jpg” then “name” has the value “img123″.

Similar binding capabilities are available for queue messages too. Assume the following queue message object:

class Order
    public string CustomerName {get;set;}
    public string OrderId {get;set;}

When a new order arrives, we are going to get the Order message from a queue and create a blob (an invoice) with the name equal to the order id. One approach is to use the IBinder interface to bind the output blob and specify the name that equals the order id. The better and simpler approach (SimpleBatch) is to bind the blob name placeholder to the queue message properties:

public static void ProcessOrder(
    [QueueInput("orders")] Order newOrder,
    [BlobOutput("invoices/{OrderId}")] TextWriter invoice)
    // Code that creates the invoice

The {OrderId} placeholder from the blob name gets its value from the OrderId property of the newOrder object. For example, newOrder is (JSON): {"CustomerName":"Victor","OrderId":"abc42"} then the output blob name is “invoices/abc42″. The placeholder is case-sensitive.

Books 2013

 Jan 4th, 2014 


Following last year’s tradition of writing about the books I read in the previous year, here is the list of books I read in 2013:


One Up On Wall Street: How To Use What You Already Know To Make Money In


The 7 Habits of Highly Effective People: Powerful Lessons in Personal Change


Harry Potter and the Philosopher’ Stone


Harry Potter and the Chamber of Secrets


Harry Potter and the Prisoner of Azkaban


Harry Potter and the Goblet of Fire


Harry Potter and the Order of the Phoenix


Harry Potter and the Half-Blood Prince


Harry Potter and the Deathly Hallows


Broken Genius: The Rise and Fall of William Shockley


The Box: How the Shipping Container Made the World Smaller and the World Economy Bigger


Forrest Gump


The Millionaire Mind

Which was the best? Surprisingly, the history of the shipping container is more fascinating than you would expect. The Box is a must read for every one and the learnings from it apply in the software industry too.

I am starting 2014 with two books on my reading list:

moonwalking cover

Moonwalking with Einstein: The Art and Science of Remembering Everything


For a Song and a Hundred Songs: A Poet’s Journey Through a Chinese Prison

The case of a hard to reproduce bug

 Dec 28th, 2013 


This is the story of a bug that was hard to reproduce. It is about the investigation and it shows how well intended code can make bugs even harder to reproduce. The bug (and the fix) is trivial. However, a combination of factors make it remarkable.

When Know Inc. starts for the first time after a clean installation, it displays a popup window with an introduction to the game. After the dialog closes it should not show up again. However, on some installations, the dialog would still appears on the second or even third game start. This would happen until a mission was started. Then, it would stop showing up no matter what. The bug was reported about a month ago and until two days ago I was not able to reproduce it.

I uninstalled the game on my phone and reinstalled it from the Store. Then I noticed that every time I start the game, I get the intro popup. On Windows Phone, if you install the game from the Store you cannot access the isolated storage where the files are stored. That can only be done for side-loaded applications. So I had the bug reproducing on my phone but no way to investigate.

I uninstalled the store version of the game and installed the developer version so I can debug. Guess what? I couldn’t reproduce it anymore. At least I knew that it is somehow reproducible on my phone. I tried to remember what I did with the store version before I noticed the bug. I opened the game… clicked the Story button… probably closed the game… opened it again… started a mission… dismissed the how to play dialog… closed the game… I knew it was reproducible, I just had to find the correct steps. Tried for an hour or so but nothing. At that point, I didn’t know that it only works on clean installations (you’ll see soon why). No luck, so that was it, no repro.

I was working on a new feature when I saw the bug again. Eureka! Repro on developer build. The first thing I did was Read the rest of this post »