Pedro Assunção

Archive for the ‘software development’ Category

Websockets tutorial/example with pywebsocket

As everyone already knows, Google Chrome now supports websockets. In essence, this allows you to keep a connection open with a webserver indefinitely (analogous to typical sockets) and send data bi-directionally. Unfortunately Chrome is the only browser currently supporting this, but I’m pretty sure this will change. So I decided to give this a try [...]

VLC for OSX developers needed

According to a post on their forums, there are currently 0 (zero) developers working on the OSX version of the popular video player VLC. If you know someone with Cocoa skills that wants a good challenge, pass the message on. Please do, I don’t want to lose my favorite video player of all times

Organizing texts

I recently took another look at all the different texts I wrote in the past and came to the conclusion that I really need a central place to handle all of that. Due to the fact that I don’t feel like maintaining the Java desktop application I created for that effect, I decided to put [...]

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 [...]

New programming language (GO) and new mobile OS (Bada)

Wow, these have been a couple of crazy days: First Samsung announced a new operating system for mobile devices called Bada – that will compete directly with Google’s Android – and the next day Google announces the creation of a new programming language, supposedly a cross between Python and C++, called Go. It looks like [...]

GamaRay : Open Source Augmented Reality Project

If you ever saw the GE eco website on the smartgrid, then you have experienced a bit of augmented reality using only your computer’s webcam and a piece of paper. This type of technology has now and opensource version. It’s called Gamaray, and it allows you to play around with this on your Android powered [...]

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 [...]

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: [...]

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)]

Super useful article on PostgreSQL

I’ve always been a fan of PostgreSQL, even though I’ve been forced to use MySQL at work for ages (you know, IT policies). Anyways, after reading this article I’m definitely switching all my pet projects to PostgreSQL. The documentation is amazing, the database itself is blazing fast and super scalable. And it’s open source. What [...]

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 [...]

Vimeo uploads

I’ve been recently writing a python script to upload videos to vimeo, as I usually do when I have to upload a new episode of Two Guys and a Beer. Today I believe they rolled out a new advanced upload API, though the old one should still work until November 13th. But the problem is [...]

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. [...]

WordPress: ‘publish_post’ is also triggered on subsequent post editions

If you ever dug into the wordpress plugin world you know that you can create some hooks on the wordpress flow to allow execution of your functions when something interesting happens. One of those hooks is the ‘publish_post’, which will be triggered when the post is published and – surprise – also everytime the post [...]

SSH login without password (authorized_keys)

I know that a lot of people covered this in the past but, since I also use this blog as a vault for tips that I might forget in the future, here’s how to make ssh not require you to enter a password when connecting to another machine: Step 1: Generate your public and private [...]

Migrated the blog to wordpress

Yes, once again. I know, I have no life I’m curious to see how long WordPress will last, before I get bored and try to implement everything by hand again. But, the night is over and tomorrow there is a lot of jumping to do, in Evora – Portugal. Hopefully I can get someone to jump [...]

Working on something really cool

As you might know, a while back, I started a video podcast on life, technology, and everything, with my dear friend Luis Soares (http://twitter.com/luizsoarez). You can watch the episodes here: http://vimeo.com/channels/tgab. Recently it came to our attention that we do not have a graphical identify yet (like we didn’t notice ) so work has began [...]