11 January 2015

Python Facebook tutorial - post to Facebook page in 4 steps
In this tutorial, you will learn how to post to a Facebook page's wall (acting as the page) using Python. It includes step by step instructions to create a new page, register an app with Facebook and some python code. I have a similar Python tutorial for Twitter. Step ...

02 January 2015

nginx - Image hotlink protection using rewrite
I recently setup this blog on Digital Ocean using nginx. Sometime in the past week I found that some evil sites are hotlinking my image of pink floyd album covers. Image hotlinking is when someone serves media stored on your server directly on their webpage - hence stealing bandwidth. It is ...

31 December 2014

Python Twitter tutorial - 5 steps to tweet a message from python script
In this tutorial, you will learn how to send tweets using Python. I will try to keep it as simple as possible. UPDATE: I wrote a similar Python tutorial for Facebook. Step 1 You must add your mobile phone to your Twitter profile before creating an application. Go to: Settings ...

22 October 2014

Java: sort map by values and get top N keys?
Here are two utility functions to do exactly that using Guava, inspired by this stackoverflow answer. If the values are Comparable: public static > List getTopKeys(Map map, int n) { Function getVal = Functions.forMap(map); Ordering ordering = Ordering.natural().onResultOf(getVal ...