JulioBiason.Net

Old-school coder living in a 2.0 development world.

Archive for the ‘Code’ Category

A bit about LOLCODE

without comments

Couldn’t help but laugh:

I can’t seem to find a LOLCODE (http://en.wikipedia.org/wiki/LOLCODE)
API wrapper for Twitter. I was hoping to write my next Twitter
application in LOLCODE, but its very hard to do so without one.

Can anyone help me get started with a basic program? My code so far
isn’t working

HAI
CAN HAS STDIO?
MAKE CONNECT TWITTER NAO
I HAS A VAR TWEET
IM IN YR LOOP
   UP VAR!!1
   GET UR TWEETS
   VISIBLE TWEETS
IM OUTTA YR LOOP
KTHXBYE

Thoughts? An API wrapper would make all this much easier.

David

Written by Julio Biason

July 19th, 2009 at 3:48 pm

Posted in Code,Fun

Tagged with ,

Mitter 0.4.5 “It’s a UNIX system! I know this!” released

without comments

Mitter is a simple application to keep your Twitter status up-to-date and to see your friends updates. It aims to be simple and with a small requirement list, while supporting multiple different interfaces.

Fixed in this release:

  • Missing files in the last package.

Downloads available at project page.

Written by Julio Biason

April 15th, 2009 at 12:28 am

Posted in Code,mitter

Tagged with , , ,

Mitter 0.4.4 “Hold on to your butts.” released

with 2 comments

Mitter is a simple application to keep your Twitter status up-to-date and to see your friends updates. It aims to be simple and with a small requirement list, while supporting multiple different interfaces.

Fixed in this release:

  • Fixed a problem with large avatars due Twitter not resizing them properly on uploads;
  • Fixed a crash in OS X systems.

Download available in project page.

Written by Julio Biason

April 14th, 2009 at 2:12 pm

Posted in Code,mitter

Tagged with , ,

Mitter public annoucement: Mitter is going git

without comments

Just to let everybody know: Mitter will not use Google Code SVN repositories anymore. The source is still available for those that know the URLs but the information is not available to the public anymore. Other things like Wiki, issues and downloads will still be available in the Google Code space.

Mitter source code is not being hosted with Gitorious and it’s available for everyone to clone it. Also, Gitorious offers options for automatic cloning so all you need is a Gitorius account.

Small PQA (Possibile Questions and Answers):

  • Why Git?
    For one thing, I’m feeling comfortable with Git workflow and tools. Second, I prefer the way Git does “in-place” branching, so you don’t have a lot of directories laying around your disk.
  • Why Gitorius and not GitHub?
    I know how GitHub is everybody and their mum’s favourite git repository and interface. But, as an open source supporter, I chose Gitorious exactly ’cause they provide the source code of their project for everyone. I’m not saying that GitHub is wrong charging people for their project, it’s just that I prefer to support open source.
  • What about the other branches that were laying around in the SVN repository?
    They are still there, but I didn’t import them into Gitorious. Most of them were not being used anymore but, if something is needed, the source is still there.

If you have any other questions, feel free to ask.

Written by Julio Biason

April 12th, 2009 at 8:03 pm

Posted in Code,mitter

Tagged with , , , , ,

The current state of Mitter

with 5 comments

I just tweeted about this, but better put here so everybody knows:

Mitter trunk (from SVN) is broken. Broken, broken, broken.

Why? It all started when I realized that all interfaces where saving the last seen tweet and last seen reply. Also, to cut the seen replies and tweets, the interfaces were actually removing the seen ones from the result set. In other words, we were requesting the full page of tweets/replies and then ignoring the ones whose ID was below the last one the interface displayed. Twitter supports a since_id parameter, which was created exactly for that. Also, we were requesting just the first page, so if you didn’t open Mitter for a while, you’d not see some tweets.

Also, for a long time, there is a hack to make console interfaces work properly. Due the nature of the graphical interfaces, we need to create a thread (kinda like another process, if you don’t know what a thread is) so when requesting data the interface won’t freeze. That’s not an issue for console interfaces and, to make them work properly, I had to add a hack, which make the code even uglier. The removal the thread broke the GTK interface completely… for now; I have plans on how to fix the GTK interface and they will be added as soon as I fix the network bit.

During this time, there was another thing bothering me: The amount of hard-coded values. The GTK interface, for example, only keeps 60 tweets in the list. Problem is, if you want to keep a bigger list, you’d need to change the code directly. That’s not a good solution to me, so the idea was to move everything to the config file, which pointed to the second big design issue: The options were floating all around the code. Keeping option values coming from the command line and from the config file was a mess. For that, I decided to create my own OptionParser (the command line option parser) and ConfigParser (the config file parser) combinator. Yesterday I finally finished ConfigOpt and I intend to move all Mitter options to use it (which will make our code cleaner and hard-coded values free — or so I hope.)

And, since I’m working in all that, I decided to start paving the road to multiple network support. A tiny bit of it is already there, but there is also a long way to reach the final line.

There is still a long way to finally make Mitter stable again. But we’ll get there, I promise.

Written by Julio Biason

February 10th, 2009 at 1:19 pm

setup.py, simplejson and json modules

without comments

When dealing with JSON objects in Python, we have the excellent simplejson module to convert a JSON object into Python object. But, in Python 2.6 (and 3.0), we have the json. While loading it’s as simple as

try:
    # Python 2.6/3.0 JSON parser
    import json
except ImportError:
    # Fallback to SimpleJSON
    import simplejson as json

And you would just need to use json.dump(), that leaves the problem of pointing if the application requires simplejson or not in the setup.py. The solution is use sys.version_info comparing versions with distutils.version.StrictVersion:

from distutils.version import StrictVersion

import sys
version_number = '.'.join([str(a) for a in sys.version_info[:3]])

if StrictVersion(version_number) < StrictVersion('2.6'):
    params['requires'] = ['simplejson']

Explaining:

  • First of all, params is a dictionary of parameters passed to setup (as setup(**params), as Python supports passing a dictionary as a list of parameters as a function.) Another probable solution would be use a requires variable and set it to None in case the version is superior than 2.6.
  • The version_number uses just the first three elements in sys.version_info 'cause it also contains other information like "final" or "rc" and the release info (e.g., Python 2.5rc1 would have a sys.version_info of (2, 5, 0, 'rc', 1))
  • StrictVersion provides proper comparison between versions, so you don't have to worry about Major, Minor and Release versions or even have to write three cases in an if.

Written by Julio Biason

January 9th, 2009 at 2:24 am

Posted in Code

Tagged with , , , ,

Is Mitter dead?

with 2 comments

As some may have noticed already, there haven’t been many releases of Mitter lately. But it doesn’t mean Mitter development is dead. I’ve been working on some things lately:

  • Multiple network support:
    One thing I’m trying to make now is support for multiple networks, so you could update your status on Twitter, Identi.ca, Facebook, Jaiku and whatever from just one client. The weird thing is that, this time, I decided to actually write the design down and then start working on it, to avoid creating a mess of code but, in the end, every single step I did into code proved that I forgot something (yay for Python and fast prototyping!) I still see some rough edges everywhere, but I think after a week working on it, I got a huge step forward.

  • The damn network thread:
    Not something I’ve been actively working on, but I think about it from time to time. The main reason it bothers me is the problems with the PyGTK main loop on Windows and the ugly ugly hack for the console interfaces (tty and cmd.) At first I thought about converting the network interface into a file-like object, so it would be just a matter of “read()” the data, but that proved to be a problem with the idea of multiple networks. Right now, I want to try to split the HTTPThread into a single object and the interfaces would be able to mix it with the Network/Twitter objects. So, only interfaces that need threads will have a HTTPThread-like object to use; interfaces that don’t have that problem will use the Network/Twitter object directly.

  • Tk(inter) interface:
    Also with the problem with PyGTK on Windows, I decided to play a little bit with Tkinter. Now, everyone knows that it looks pretty bad on X11 interfaces, but on Macs and specially Windows, it tries to mimic the OS look (even more on Windows, where it translates Tk commands directly into Windows.) So far, it looks alright and I even have a working prototype (not plugged into the Mitter object yet, though.) Here are some screenshots:


    The first thing you’d probably notice is that it doesn’t look like the PyGTK interface. That’s because Tk supports only one line for items on listboxes, so I had to make a space for the whole tweet or you’d get just a glimpse of the text. I’m not looking into links and other stuff yet, but maybe in the future.

Written by Julio Biason

January 8th, 2009 at 1:56 pm

Announcing aoup

without comments

“aoup” (Add-On UPdater) is a simple application to keep your World of Warcraft add-ons up-to-date with the latest version in Curse. It doesn’t intend to have a nice interface or be completely up-to-date with the latest addons; for that, you can use the official Curse client.

This is the first release and I’m aware it’s kinda annoying to use it right now, but it works. The project page is in Google Code and the source code is available in this git repo.

Edit 1: D’oh, not “annoying”.

Written by Julio Biason

December 23rd, 2008 at 2:16 pm

Posted in Code,aoup

Tagged with , , , ,

Mitter 0.4.2 “God help us; we’re in the hands of engineers” released

without comments

Mitter is a simple application to keep your Twitter status up-to-date and to see your friends updates. It aims to be simple and with a small requirement list, while supporting multiple different interfaces.

Fixed in this release:

  • Double brown paper bag release: Added missing source files in the package, necessary for the PyGTK interface.

Download available in project page.

Written by Julio Biason

November 10th, 2008 at 11:22 pm

Posted in Code,mitter

Tagged with ,

Mitter 0.4.1 “Oh my God. Do you know what this is?” released

without comments

Mitter is a simple application to keep your Twitter status up-to-date and to see your friends updates. It aims to be simple and with a small requirement list, while supporting multiple different interfaces.

Fixes in this release:

  • Added missing file in the packages

Download available in project page.

Written by Julio Biason

November 10th, 2008 at 4:21 pm

Posted in Code,mitter

Tagged with ,