Blog

During the course of the day I encounter lots of challenges, some of which take minutes to solve and others that take much longer. My goal for this section is to keep track of these challenges and their solutions. I will turn the longer ones into articles, while the shorter ones will stay as blog entries. You can expect topics to range from very specific programming challenges to broader topics like life.

Below is a list of the recent blog entries. You can also browse the blog by using the tags on the right side, or if you know what you are looking for then you can use the search box at the top right.

Interesting language

Cache’ Object Script is an interesting language. Take a look at the following two loops

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
test
	s done=0
	f ln=1:1:10 d  q:done
	. w !,ln
	. i ln=5 s done=1
	w !,"ln after loop "_ln
	q
test2
	s done=0
	f ln=1:1:10 q:done  d
	. w !,ln
	. i ln=5 s done=1
	w !,"ln after loop "_ln
	q

The goal is stop after five iterations and then use the ending index to do something more. Executing the above code results in…

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
PLAY>d test

1
2
3
4
5
ln after loop 5
PLAY>d test2

1
2
3
4
5
ln after loop 6
PLAY>

Can you spot the difference?

Vista SP2 and UltraMon

So, with Service Pack 2 beta installed on my Windows Vista x64 machine Windows Explorer would crash every time I would mouse over a program entry in the taskbar. After a few crashes I noticed that UltraMon was causing this behavior (even with the smart taskbar disabled). I was running UltraMon 3.0.2 and checking on UltraMon’s site I noticed that they had 3.0.3 beta available. So, I upgraded to that and now the crashes are gone. Hopefully this will save you some time in case if you have UltraMon installed and are trying out SP2 beta. Other than this issue everything else seems pretty good (I have only used it for a few hours now).

Vista Service Pack 2

Upgraded the tablet to Vista Service Pack 2 Beta, let’s see how this goes. So far things are pretty good (the hard disk seems to be quieter, but that might just be psychological).

Windows Vista Service Pack 2

Pleasant surprise

Lately I have been playing around with Minefield (i.e. the development of firefox 3.1) with all its goodness of just in time (JIT) Javascript feature. Today I was browsing through its source code viewer and noticed something different. The JavaScript, CSS and other includes were actually links! How nice! 🙂 Now you don’t have figure out whether something is coming from the root or some other intertwined directory, just click and you are good to go. You can even drag and drop image reference to a tab and it will load from the correct location.

Take a look at the screenshot below to see for yourself 🙂

Firefox 3.1's source code viewer

New article posted

I just posted a new article about fixing offline files in Windows Vista. Take a look!

Project logic, coded!

The other day I was thinking if there was a logic to how I took on new projects and actually performed them. So, last night I wrote the following python program

This is some imaginary python code reflecting my current state of mind as it relates to work/side projects. Do you have any advice for me? Code it in the comments! 🙂

Read full post...

New computer, and “64-bit thoughts”

System properties showing the 64-bit Windows Vista

About a week and a half ago I built a new computer, and after doing a lot of research on 64-bit operating systems I finally decided that it was time that I switched. I am using plurals (operating system_s_) because once I switch to the new computer I was going to move the “older” one to become the server. One additional attraction for going to 64-bit on the main computer was that I was getting 4GB of RAM, which 32-bit Windows doesn’t completely utilize due to technical limitations.

Read full post...

I am in love…

…with a font, that is! 🙂 If you haven’t guessed already, I like to write code. So, naturally, the one thing that I see the most during a normal day is fixed width font. Previously I didn’t care so much and used whatever default the operating system had. On Windows this is generally the [Courier New)] font. Recently, I started to look around to “spice up” my environment, and font was the first thing that came to my mind. So, I started looking around for options and ended up on Consolas.

A screen shot of Consolas in VIM

Now, nothing is perfect and Consolas is no different. Consolas was designed with ClearType and pretty much for ClearType because it doesn’t look very good if you don’t have ClearType enabled (checkout the comparison in the wikipedia entry). That is something that I can live with because majority of the coding that I do is either through a shell session running on Windows or in some other Windows programs so it isn’t really an issue for me. For the cases when I do have to use other operating system, there is always the similar looking Inconsolata font.

To really enjoy this font I have all my fixed width programs set to 10pt font size, which I have noticed is the best size for this font. At this size the font looks awesome and you can easily distinguish the similar looking characters like o (lower case o), O (upper case O), and 0 (zero).

So, if you code a lot or look at fixed width fonts all day long for some other reason then I suggest that you should give this font a try, maybe, you too will fall in love with it! =D It comes standard on Windows Vista, for other Windows version you can download the Consolas Font Pack if you have Visual Studio.

If you are looking for some other options you might also want to consider another excellent font that supports box drawing: Envy Code R.

gawk script for updating your models.py

Last evening I updated my django source to the latest SVN and found a surprise. The latest set of backwards incompatible changes were affecting my project. Specifically the new ModelAdmin moves were making things hard for me. Given that I have a few applications in django, I decided to write a script that would help speed up the process. What I ended up with was a simple gawk script that processes the models.py file and outputs the code for new ModelAdmin classes. I still have to manually remove the original admin classes because I didn’t want this to mess up things, but not having to look through the models and copy-pasting should save you some time.

For instance, if your models.py has three models-Tag, TaggedItem and NodeGroup-with Admin classes defined then this script will print out…

$ awk -f admin_model.awk models.py
class NodeGroupAdmin(admin.ModelAdmin):
                date_hierarchy = 'created_on'
                list_per_page = 25
                search_fields = ('title', )
                list_display_links = ('title',)
                list_display = ('id', 'title', 'created_on', 'updated_on', 'published', 'group_type',)
                list_filter = ('published','group_type',)
class TaggedItemAdmin(admin.ModelAdmin):
                pass
class TagAdmin(admin.ModelAdmin):
                pass
admin.site.register(Tag, TagAdmin)
admin.site.register(TaggedItem, TaggedItemAdmin)
admin.site.register(NodeGroup, NodeGroupAdmin)
$

I have added the usage instructions at the top of the script, and here is the script.

Getting psycopg2 to work in cygwin

A few months ago I tried to setup django with Postgresql in Windows through cygwin. Part of this setup included installing the pyscopg2 module for python. Interestingly everything would compile and install OK, but when it came time to import the module, python would complain that it couldn’t find a file, specifically _psycopg.

>>> import psycopg2
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/site-packages/psycopg2/__init__.py", line 60, in <module>
    from _psycopg import BINARY, NUMBER, STRING, DATETIME, ROWID
ImportError: No such file or directory

At first I decided to let it slide and do away with cygwin and go the Windows python route for the normal development, and using my “500MHz overclocked to 555MHz linux machine” to do advanced stuff. Lately this solution has been painful because of the background jobs has a significant difference in processing time; by significant I mean 22 minutes vs 5 minutes! So, over the past few days I decided that I was going to find out the solution to this. I started my investigation the normal way, doing some research on my own, checking in the IRC channels for python, asking on the psycopg mailing list, but no luck!

Read full post...