Pedro Assunção

Archive for the ‘tips’ Category

Android location provider mock

So, yeah, I resumed playing around with android, this time version 2.0. I’m really tempted to buy the new Motorola Milestone that should come out in Europe sometime between… now… and early next year, so I wanna be ready to create all the crazy stuff I have in mind for it One of the things [...]

Happiness hat

Holly crap, just when you think every weird thing has been invented here comes a new one to blow your mind. Introducing the happiness hat, the clothing accessory that makes sure you always have a smile on your face. Either that or you will experience intense pain until you do. From their website: “Frowning creates [...]

junaio – 3D mobile augmented reality for iphone

I, like some people, heard about layar before, and how you can augment what you see through your phone. These guys (Junaio), however, go a step further and have the ability to add cool content to the reality scenes (like 3D objects for example). Checkout the video and learn more. YouTube – junaio – 3D [...]

Blog usability tips

I recently came across a really useful article about blog usability tips. I still think the best tip for any blogger is to write about things he/she is passionate about, but these can give you a bit of a boost presenting your content. Here’s my take on some of their tips: Pick a topic for [...]

Grabbing title tag from web page

At least a couple of options, the first using BeautifulSoup: import urllib import BeautifulSoup soup = BeautifulSoup.BeautifulSoup(urllib.urlopen(“https://www.google.com”)) print soup.title.string And the second one using lxml: import lxml.html t = lxml.html.parse(url) print t.find(“.//title”).text

Fabric for remote deployment

I recently came across a piece of software called “Fabric”. It has been made in python and its purpose is to help simplifying the process of deploying software to remote machines. The really cool thing I like about it is that it’s much faster than, say, an ant script because it actually reuses the SSH [...]

Using google wave to organize events

This thing is going to be really useful. Say, for instance, I want to organize a skydiving trip with some friends. I can just create a wave, throw in a map of the destination, along with the weather on that particular date, discuss about all of the options, attach pictures. Simply awesome!

Django template filter: Show list of objects as table with fixed number of columns

I recently ran into the following problem: I needed to be able to display a list of users in a table that had a maximum of X columns. Since I could not find the solution on the Internet I decided to give it a try and here is my resulting template filter to do it: [...]

Lunch reading habits

Lately I’ve been grabbing a couple of Paul Graham’s essays just before lunch and devouring them along with the meal. And I must say I’m getting addicted to them. He is clearly a well lived, intelligent person whose writing can be really inspiring to everyone, especially developers like me. I recommend, with no particular order, [...]

OSX: Preventing iTunes from launching when pressing multimedia key

If, like me, you have this annoying problem where iTunes insists on launching every time you press a multimedia key on your keyboard (for instance play/pause/next/previous song) the fastest and most effective way to work around it is to get rid of iTunes completely: Move iTunes to the trash (from the applications folder); Move FrontRow [...]

Python: Sort list of tuples by second item

Straight from the PythonInfo Wiki: >>> import operator >>> L = [('c', 2), ('d', 1), ('a', 4), ('b', 3)] >>> map(operator.itemgetter(0), L) ['c', 'd', 'a', 'b'] >>> map(operator.itemgetter(1), L) [2, 1, 4, 3] >>> sorted(L, key=operator.itemgetter(1)) [('d', 1), ('c', 2), ('b', 3), ('a', 4)]

Trying to become an early riser

After reading a post by Steve Pavlina I thought if  I could become a natural early riser, i.e, someone that gets up really early in the morning and has no problem with that. I felt curious when I read that, after turning into an early riser, he became more productive and felt more refreshed throughout [...]

Django: Reverse HTTP redirect with parameters

Here’s how to, from a view, redirect to another URL passing parameters to it. For instance, to redirect the user to a certain page after login: return HttpResponseRedirect(reverse(‘dz_details’, kwargs={‘dz_id’:dz.id})) This will lookup the ‘dz_details’ name in your urls.py file, which could be defined like so: url(r’^details/(\d+)/$’, views.dz_details, name=’dz_details’), There is a simpler way to do [...]

[Django] Dynamic redirection after login

Here’s how to redirect to the login page in django, making it go to a certain view (by name) after a successful login: login_url = ‘%s?next=%s’ % (reverse(‘acct_login’), reverse(‘jumplog_index’)) return HttpResponseRedirect(login_url) Notes: acct_login is django’s view name for the login page (double check this, as it might change in future django versions); jumplog_index is the [...]

Java HTTP proxy servlet (with Spring)

I always wanted to build my own proxy. I’m kidding. I do have better things to do with my time. Nevertheless, a problem presented itself and here’s my solution for it: An HTTP proxy Spring controller. Currently: Handles GET and POST methods; Guaranties the type of the response to be the one the target server [...]

JIRA issues reporting with Python

I recently took interest in knowing how one of the projects I worked previously had evolved in JIRA over time. So I decided to write a python script to do it for me. Turns out it’s pretty easy, using the xmlrpclib that comes with python, if your JIRA installation has this remote entry point enabled. [...]