Filtering QTreeView
While working on my newest project, I had a miserable time figuring out how to filter sub-items in QTreeView and its associated models (like in kopete/pidgin). The first thing to do is to use QSortFilterProxy as a middleman. The problem is that QSortFilterProxy will only search top level tree nodes.
The way to implement custom filters is to subclass QSortFilterProxy and reimplement filterAcceptsRow(). But I couldn't figure out any way to quickly access sub elements using QModelIndex, nor could I find anything on the 'net.…
Read more ⟶
Installing Arch linux on the HP DV6910TX
This is a record of my attempt to put Arch (2008.06 Core Dump) on the HP DV6910TX.
Here is my system configuration
Intel Core 2 Duo T5750 @ 2.00GHzRam : 3GBNvidia GeForce 8400M GS with 256Mb dedicated memory320Gb harddiskPartitioning
Here was my original partitioning scheme:
C: 308GbD: (Recovery) ~10Gb
Make sure you create your HP Recovery Discs first!
Since the arch install CD doesn't have ntfsprogs ( it has the packages, but not as part of the setup boot ), I booted from dreamlinux (you can use any liveCD) and used ntfsresize to shrink the C: (/dev/sda1) to 35Gb.…
Read more ⟶
Random Ramblings
Sorry for not blogging in a long time. This has been a very busy week, and so I'm just going to drop some snippets.
First RMS and Larry Ellison both commented against cloud computing.
Graffiti is uploaded and ready to use ( but not necessarily stable ).
I read Snow Crash and loved it.
I'm confused between getting a Dell Studio 15 and HP Pavilion dv6767tx.
Meanwhile I'll be leaving for Pune tomorrow for SUMMIT '08 at MIT Pune.…
Read more ⟶
Graffiti is almost released
Aside from some code cleanup, testing, and writing architecture documentation, Graffiti is good to go. You can Download it …
Read more ⟶
Reworked Graffiti's first render
After quite a few weeks of work, Graffiti has (again) reached the stage where it can render it's first words. It's now at 488 lines of code, of which the CSS related stuff itself comes in at 288 lines! There is no word wrapping yet, or any layout logic. I've been busy fixing quite a few bugs in the CSS overlays and so on.
This is how you would use it.…
Read more ⟶
Nikhil meet Archlinux and KDE4
I've been home (Mumbai) this weekend and have been hacking away for the last two days to get Arch running on my external HDD, since I can't stand Mandriva anymore. The cool thing about Arch and Pacman is their flexibility. Following this guide I was able to install Arch from within my internal hdd arch, and have all the latest packages (including KDE 4.1).
There was only one problem which wasn't mentioned.…
Read more ⟶
Custom hash objects in Python
It's quite common to use strings, integers and other 'native' Python data types as hash keys. But sometimes it is much easier to be able to use your own class instances as keys. Python's magic methods allow you to do this.
Note: This is not a tip on implementing hash functions, this is how you can remove a certain layer of peeking around into objects
__hash and __cmp__
Consider a useless HTML parser with a simple node design where you want to associate the node name with its attributes.…
Read more ⟶
Sierpinski, my first fractal
The Sierpinski triangle in Python, inspired by HTDP, and using Pygame
import sys
import pygame
from pygame.locals import *
class Point(object):
def __init__(self, x, y):
self.x, self.y = x, y
def distance_sq(self, other):
return (self.x-other.x)**2 + (self.y-other.y)**2
def distance(self, other):
return sqrt(self.distance_sq(other))
def tupl(self):
return (self.x, self.y)
def midpt(p1, p2):
return Point( (p1.x+p2.x)/2, (p1.y+p2.y)/2 )
def too_small(p1, p2, p3):
return max([ p1.distance_sq(p2), p2.distance_sq(p3), p3.distance_sq(p1) ]) < 5
def draw_line(p1, p2, surf, col):…
Read more ⟶
Great Weekend
So my second weekend in this place went pretty great. Now that I've found the right computer which easily boots from external devices I'm ready to slowly begin coding. On saturday five of us saw Ugly and Pagli — crappy movie — but I got my first pair of studs. Its been raining a lot for the last three days here. It starts at around 7 and goes on till late into the night, which means a lot of fun football (I've discovered that playing barefoot is better than playing with normal shoes), but being cooped up in the rooms afterwards.…
Read more ⟶
A bit of improvement
I'm in the institute lab right now, booting from a pen drive (Slax). But tomorrow I'll get my external HDD and plug it in and try to be productive. These labs are only meant for 'academics' which means there are caps on downloads, so I can't even download firefox without it being interrupted. Also we haven't got our IDs yet, so this connection is thanks to a senior who was kind enough to let me use his account.…
Read more ⟶