meetteem: tech addict

software development, etc.

Pownce!

I'm on Pownce!

From the about page:

Pownce is a way to send stuff to your friends. What kind of stuff? You can send just about anything: music, photos, messages, links, events, and more. You can do it all on our web site, or install our lightweight desktop software that lets you get out of the browser.

And it's made with Django!

Sign up now and add me!

uuid.h: No such file or directory

Last month, I tried installing Apache2 in my Macbook using MacPorts. The installation failed in the installation of a dependency apr, and port install ended with this error:

misc/unix/rand.c:39:18: error: uuid.h: No such file or directory
make[1]: *** [misc/unix/rand.lo] Error 1
make: *** [all-recursive] Error 1

I never solved this problem after all the googling I did. I gave up on installing Apache2.

But the problem emerged again when I tried installing the py25-gtk package, a dependency of TinyERP. I installed ossp-uuid. Nope. That didn't solve the problem. After looking around the include folders, I found the built-in uuid.h in /usr/include/uuid/. I tried linking uuid.h to the include directory:

~$ cd /usr/include
/usr/include$ sudo ln -nfs uuid/uuid.h uuid.h

It worked. The compilation went smoothly.

Now all that's left to do is hope that everything will work out fine.

My First Merb App

I created a simple Merb application which formats Python/Ruby code into HTML, with syntax highlighting. It is powered by Pygments, a powerful syntax highlighting engine written in Python. I limited the languages to Ruby and Python.

I made this application to take a better look at Merb. Merb is a great Ruby framework. It's simple, it has great abstractions and the components are loosely coupled. And I always find myself thinking of Django when I code in Merb and DataMapper. The thought that Merb + DataMapper = Django just keeps coming back. And I love Django.

Along the way, I learned how to use pipes in Ruby. I used Open3::popen3 to pipe the text from Merb and read the STDOUT of pygmentize. I'm unsure if this method is safe.

I also learned how to deploy a Merb app, using some Rails/Mongrel/Apache recipes from Slicehost, and Merb's wiki.

So, there it is. My first Merb application. I'll upload the source code of this app soon.

Django Offline Documentation in OS X

In my development machine, I set up the Firefox Bookmarks toolbar to have easy access to various documentation. I like to have the documentation even when I am offline. So, I generated mostly the Ruby-based documentation in Rails using the built-in rake task, put them somewhere in the system, then bookmark their index page in Firefox. I also downloaded the Python documentation, extracted the tar ball, and bookmarked it. The latest addition to the bookmarks toolbar is the Erlang documentation. Hence, all of my bookmarks are available offline. Except Django's documentation.

Look at my Bookmarks toolbar

The bookmark I have is linked to the documentation in Django's site. So after my daily svn update, I delved into the docs folder. There a Makefile led the list of files. I quickly opened it in my text editor. Wow, Sphinx. I recalled stumbling upon Sphinx last month when I was researching on Ultrasphinx, the Rails plugin for full-text search that uses the Sphinx search engine.

So I installed Sphinx using EasyInstall (I was using MacPorts so EasyInstall was already installed.):

sudo easy_install-2.5 Sphinx

After that, I went to the directory and maked the html documentation:

cd /usr/local/src/django/docs
/usr/local/src/django/docs$ make
Please use `make <target>' where <target> is one of
  html      to make standalone HTML files
  web       to make files usable by Sphinx.web
  htmlhelp  to make HTML files and a HTML help project
  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter
  changes   to make an overview over all changed/added/deprecated items
  linkcheck to check all external links for integrity
/usr/local/src/django/docs$ make html
mkdir -p _build/html _build/doctrees
sphinx-build -b html -d _build/doctrees   . _build/html
Sphinx v0.1.61950, building html
...

Now, I have the Django documentation in my local machine in $DJANGO/docs/_build/html, and it's easily accessible via my Firefox Bookmark toolbar. The offline documentation doesn't look as beautiful as the online one, but I can live with that.

Comments At Last

I added a simple comment system to this blog after a little thinking about the way to handle spam comments. I hope this works smoothly.

I used Django newforms to implement the comment form and validation.

Deployment was a little bit rough as it involved adding a new model to the app, and I forgot to update the tables in the production. And I failed the first time I tried to add the tables using the .sql file I generated from manage.py sqlall. My dev machine runs PostgreSQL but
timmedina.com uses MySQL. That caused access to posts 500s.

You can only comment from a post's page, not in the index, category, and monthly archive pages. Try it out. ;)

A Simple Erlang Exercise: the Fibonacci Sequence

I love learning and checking out stuff.

Today, the geek in me has, once again, been satisfied. Sort of. To culminate my Erlang adventure which I started today, I decided to do a simple exercise: the classic Fibonacci sequence. The function interface is simple: fibo(x, y, n), where x and y are the first to elements of the sequence, and n is the number of elements in the sequence and assumed to be at least two-- the first two elements, and in the true Fibonacci sequence, x is 0 and y is 1.

For example, fibo(1, 20, 4) will yield [1, 20, 21, 41] and fibo(0, 1, 8) will yield [0, 1, 1, 2, 3, 5, 8, 13].

Here's my solution:

-module(fibo).
-export([fibo/3]).

fibo(_, _, 0) -> [];
fibo(X, Y, N) -> [X|fibo(Y, X+Y, N-1)].

I'm an Erlang newbie and I'm finding it difficult to think in Erlang. Recursions, recursions! Yum! But it's always cool to learn "new" ways of looking at problems.

And I also implemented a non-recursive solution in Python:

def fibo(x, y, n):
    res = [x, y]
    zo = y
    z = x + zo
    for i in range(n-2):
        res.append(z)
        z, zo = zo + z, z
    return res

.ssh/config

For security reasons, I set ssh ports in my boxes to something other than standard port 22. There are consequences to this practice, like when accessing subversion or git repositories over ssh.

Usually you checkout or whatever to repository over ssh using svn co svn+ssh://user@host/path/to/proj/trunk. I've blogged about how to use svn+some_other_name if subversion uses other non-standard port.

But what about git? Or just plain ssh? Do you have to type ssh -p <someport> everytime?

Nope. You can fine tune ssh to use different settings for different hosts. Just drop in config in your $HOME/.ssh/ with the following contents:

host <host1>
user <username>
port <portxxx>

host <host2>
...

And voila! You can access your subversion or git repository, or just connect to your host via ssh using just the host, without specifying the user and the port. SSH will automatically use the config.

Flat Pages in the House!

I wanted to have an About page for this blog, like most blogs do. After quickly going through the Django flatpages documentation, I was ready to take the leap. Well, it wasn't really a leap coz the whole thing involved around five steps excluding the actual adding of the content. Nice and simple.

And so here it is- my first flatpage ever- the About Me page. Of course, I haven't thought much what to write about myself. I'll update it when I have the time. I've been busy in the past few days with a Rails project.

Still no comments system, but I guess it's okay because no one ever reads my blog anyway.

First Post!

After a few days of reading Django's documentation and the Django book, I've created this blog app using Django. I originally started implementing this blog app with Merb but changed my mind with the release of Google App Engine.

I blogged about this in my Wordpress blog, and since this blog doesn't have a comments system yet, you can comment there instead. Reactions and the like are very welcome and will be very much appreciated.

A few more tweaks and features and I'll make this my blog on software development and other geeky stuff.