PyGTK Tab-Completion

PyGTK – EntryCompletion hacked up to give nicer tab-completion (PasteBin.ca) (GitHub)

While working on a batch organizing tool, I found out the hard way that GTK’s EntryCompletion is not meant for people who want speed. (It’s a memory aid, not a speed aid) I also couldn’t just switch to PyQt or wxPython because they all do basically the same thing.

As such, I hacked the GTK auto-complete up a bit so that it behaves more like shell auto-complete. (It doesn’t do anything until you hit Tab. When you do, if there’s one match, it’s completed. If there are multiple matches, it pops open the normal auto-complete list so you can pick one.

Hope this help someone. I know I would have liked to find this in my Google results.

Update: If you’d like to preserve normal tab behaviour when the box is empty, just change line 28 to if event.keyval == KEY_TAB and self.get_text():. Of course, make sure you explain the behaviour and provide some sort of workaround for tabbing when the field isn’t empty. (In my app, pressing enter to submit the contents and clear the field is a perfectly acceptable solution)

Posted in Geek Stuff | 1 Comment

Setting memory limits on Linux

You might not be aware of this, but since some time during the glibc 2.3 era, Linux apparently doesn’t enforce the RSS memory limit. (ulimit -m) My tests seem to confirm this.

As such, the only way I could find to limit a program’s memory allocations was by the VIRT size (ulimit -v)… which can differ a lot from the RSS. (Upon which the “percentage of memory used” value in system monitors is based on, if you weren’t sure)

Firefox exhibited the greatest difference I could find with just over 900MB VIRT and roughly 300MB RSS while having 48 tabs open. However, the highest I could get any program to go was 1021MB with GIMP while editing a 5000×5000 image. (I use them for practicing drawing with my Wacom tablet) In general, VIRT ranged from RSS + 200MB to RSS * 3.

Therefore, if you have a lot of RAM, you want to set a limit that can only be crossed by misbehaving programs, and you use resource-heavy stuff, I’d suggest a VIRT limit in the range of 1.2GB to 2.0GB. If you aren’t a heavy user, 800MB to 1GB should do it. (Lighter Firefox use and use of torrent clients which use mmap() produced VIRT sizes in the 600-700MB range)

Of course, if you’ve got the time, it’s always best to just open up top, KSysGuard, or whatever other system monitor you prefer, test out your favorite apps, and see where their memory usage peaks.

If you want to set it system wide, the equivalent keyword to ulimit -v in /etc/security/limits.conf is as.

Posted in Geek Stuff | 1 Comment

Music – MC Chris – Nrrrd Grrrl

Ever seen the Fett’s Vette vid? What about this part of AMV Hell 4?

Well, in case you haven’t, both “The Tussin” and “Fett’s Vette” are by MC Chris and he’s currently running a fan music video contest for his new song, “Nrrrd Grrrl”. (YouTube Results)

You may not know how to make a music video and, while I have the general idea, I don’t have time. Either way, I suggest you drop by his MySpace page and hit the download link in the music player. The song’s pretty catchy and I doubt it’ll be in the player forever.

Posted in Geek Stuff, Music, Web Wandering & Opinion | Leave a comment

The Streisand Effect

Ever heard of the Streisand Effect? It refers to how, as John Gilmore said, “The Net interprets censorship as damage and routes around it.”

Want some examples?

Just a little something I ran across which I thought to be noteworthy.

Posted in Web Wandering & Opinion | Leave a comment

BBC: ‘Chaos’ of China’s music industry

BBC: ‘Chaos’ of China’s music industry

An interesting little article about how the music industry in China is taking a different approach to “music piracy” because there’s just so darn much of it.

Posted in Geek Stuff, Web Wandering & Opinion | Leave a comment

Fanfiction – Wild Magic

Wild Magic by Usagi Hasano

Length: 19 Chapters, Ongoing
Sources: Ranma ½, Harry Potter, Slayers, Tenchi Muyo, Sailor Moon
Rating: 5/5

Now for another one of those fics which works better than you’d expect it to. “Wild Magic” by Usagi-Hasano. In this case, the premise is “Voldemort Kills Ranma and he gets reincarnated as Draco Malfoy’s twin sister… reincarnation of Lina Inverse”.

Now that I’ve lost half my audience, let me say that, interestingly, that’s exactly why I like it. It manages to make what could easily be an insanely over-powered Ranma but it doesn’t succomb to DBZ syndrome and it continues to focus on the characters’ personalities rather than their powers.

Don’t believe me? Here are some of the reasons I like this fic: (Warning: Spoilers)

  • It is the only story I can remember running into in which someone (in this case, Ranma) dies, comes back with their memory intact, and reestablishes contact with certain people from their previous life. This is one of those ideas I think needs to be used more… by people who can pull it off, of course.
  • It has Xelloss in it. He’s always fun.
  • After Ranma returns, It’s revealed that both Narcissa and Nodoka are descended from Lina Inverse… a fact which Ranma doesn’t appreciate in light of why he supposedly had to reincarnate in the first place.
  • It has Washuu in it. She’s always fun.
  • Washuu uses the cuppy-cake song to incapacitate Xelloss and later on, Ranma/Lina uses Barney in a similar fashion.
  • In order to save Ranma’s life after the knowledge of the Dragon Slave resurfaces in just the wrong way and at just the wrong time, Washuu has to mix in some Masu. Ranma immediately knocks herself out by running full-tilt into a wall without knowing how to trigger her new phasing ability.
  • Dumbledore meets Washuu
  • Washuu decides to give Ranma a cabbit partner… a cheeky talking one.
  • Fluffy ends up seeing Ranma as scarier than Hagrid and acting like an oversized version of Fang… and later on, a similar situation occurs with Norbert.
  • It has a reasonably believable slow personality merge between Ranma and Lina Inverse.
  • Ranma is unamused by the fact that each of her “Yeah. as if…” statements eventually come true.
  • It’s interesting to see “Lina Inverse Malfoy” run into the occasional person from Nerima. A 29-year-old Ryoga, for example.
  • Xellos clues Ranma/Lina into the fact that “sore wa himitsu desu” is fun and, with Masu teleportation abilities, she has everything she needs to do it properly.
  • Showing the Malfoys as being more than one-dimensional nasties. Could have been done better, but I like it anyway.
  • Lina/Ranma gets away with refusing to obey the underage magic restrictions because, as she tells Minister Fudge, she’s been doing it since she was two years old, she could easily reduce the ministry building to a smoking crater (not that she would, of course), her flight and teleportation abilities aren’t magic, she doesn’t need a wand to do magic, and the only reason she’s even attending Hogwarts is because Dumbledore talked her into it.
  • Ranma and her Cabbit discover the Silver Millennium ruins on the moon… something which makes Washuu very happy once she gets over the surprise at having missed them.
  • Laira (Ranma’s cabbit) gains a furry child form after eating an enchanted silver millennium sword. (and is very glad to finally have hands)
  • Lina ends up getting Moaning Myrtle to laugh when she uses some astral magic to literally kick Peeves out… complete with “Stay out of the girls’ loo, ya freak!”
  • During exams, Ranma/Lina accidentally triggers a school-wide pineapple chase culminating in a fruit Riverdance because her control slipped while making a pineapple tap dance.
  • …and more…

My only real complaint about the plot is that, in the latter chapters, it’s starting to feel more like a Slayers – Harry Potter crossover when, in the earlier chapters, it felt like a Ranma – Tenchi Muyo – Harry Potter crossover… which I preferred more. Of course, from an objective point of view, that’s still a bad thing because people who prefer how it starts may dislike what it becomes and people who would like what it becomes might not be interested in how it starts.

Some of the characterizations could be tweaked in the early episodes (primarily Voldemort, the Malfoys, and some of the Nerima regulars) and I’m not too pleased with one of the jokes at Ranma’s expense later on (Sailor Pompoms), but nonetheless I enjoyed it very much. (On the plus side, I think the tweaks could be made without altering the overall plot) Keep in mind that I normally don’t accept characterization mistakes, but in this case, I enjoy it enough to make a small exception. Take that as you will when deciding whether you might like this fic. The grammar is excellent and I’ve noticed almost no spelling errors.

Posted in Fanfiction | Leave a comment

Reflections on Trusting Trust

Reflections on Trusting Trust by Ken Thompson

I read this classic article several years ago and then forgot where it was and what it was called. I’ve finally found it again and I think that it’s something everyone should read.

It’s a perfect example of why trusting both the components of your system and the people who provide them is so important.

Posted in Geek Stuff | Leave a comment