gmail-notifier

I finally got around to putting my gmail-notifier and generic-notifier up on github. They're tiny scripts that sit in your taskbar and notify you of new emails and whatnot.

Initially, I only needed a userland daemon that would poll gmail at specified intervals and send destop notifications that integrate with Ubuntu derivatives. I had written a shell script to do just that using wget and notify-send, but then I started working on machines that weren't using libnotify, so a better solution was in order.

I needed something to sit in the taskbar, have an easy way to change account settings, and fallaback to an at least decent notification bubble if it couldn't use libnotify. Qt offered a remarkably simple GUI setup, decent fallback for notifications, and python bindings. Pynotify (now python-notify) has python bindings for libnotify, but not everyone had pynotify installed back then. Dbus-python was more likely to be on systems that supported the notification spec (since that relies on dbus). I gave up trying to decide which to use, and just did both. Now I had a gmail scraper that did everything I wanted it to.

Gatlin pointed out that quite a few people could use something like this, so I decided to write a more generic version. I designed it so that, to extend the functionality to a different type of account, you would extend the GenericNotifier and PollingDaemon classes. The idea behind this was to have a different process running for each account. Why use threads and manage your own resources when the OS can do it for you?

That said, I'm starting to think that having a manager process running that just forks the different PollingDaemons would be a better UI design.

What do you think?

Now with 100% more mobile UI!

After finally getting one of these new-fangled mobile internet browsing devices, I became quickly annoyed that my own blag didn't have any sort of mobile UI. Enter the Mobile Theme module and my own variant of the Adaptivetheme Mobile theme. I haven't noticed any problems with it yet, but I'm sure some will pop up soon.

Your code snippet for this post is the entirety of the base.css for the mobile theme.

gmail-command

It turns out text messages from my phone to an email address are free. Google calendar can send sms notifications for calendar events. So now I'm working on a command interface that scrapes gmail messages and does... things. I'd send a text message from my phone, say "Tuesday, 3:00p, Meeting", and it would automagically add the calendar entry.

I know you're listening. Comment on it!

The 'correct' way to write in brainfuck

If you haven't heard about it, Brainfuck is one of those esoteric programming languages. When one is learning a language, it's customary that the first program they write simply outputs "Hello World". They then usually go on to do more complex things. Not so for Brainfuck, in which simple output is an exercise in reading an ASCII table and learning how to multiply with loops and pointers. This usually leads to long strings of things like ++++++[->+++++<]>, which are a pain in the ass to type out.

A wild python script appears.

  1. import sys
  2.  
  3. text = str(sys.argv[1])
  4. for letter in text:
  5.         ascii = ord(letter)
  6.         print "[-]>[-]<","+"*10,"[->","+"*(ascii/10),"<]>","+"*(ascii%10),"."

Something About Firefox

Soon, very soon, the Firefox devs will ship Firefox with a UI that doesn't require tweaking to not look like complete ass. I have great hope for them. Until then, there's always tweaking ~/.mozilla/firefox/[profile]/chrome/userChrome.css:

  1. toolbar{
  2.         height: 32px;
  3.         margin-top: 0px;
  4.         overflow: hidden;
  5. }

I have to use this little tweak on my desktop to keep the Stumbleupon buttons from taking up 48-64 pixels, depending on whether it's Thursday and the SU crew have 'fixed' anything recently. Thankfully, the Mozilla team have a pretty decent documentation of userChrome.css.

Screenshot Scripts

I've been using these for as long as I can remember.

For snapshots of a specific window:

  1. #!/bin/bash
  2.  
  3. picdir='/home/tron/pictures/snapshots'
  4. i=$(ls -1 ${picdir} | grep -o '[0-9]*' | sort -n | tail -n 1)
  5. xwd | convert - ${picdir}/snapshot$(($i+1)).png
  6. convert -thumbnail 100x100 ${picdir}/snapshot$(($i+1)).png \
  7.         ${picdir}/thumbs/snapshot$(($i+1)).thumb.png

For snapshots of the whole screen (everything that X is currently drawing):

  1. #!/bin/bash
  2.  
  3. picdir='/home/tron/pictures/snapshots'
  4. i=$(ls -1 ${picdir} | grep -o '[0-9]*' | sort -n | tail -n 1)
  5. xwd -root | convert - ${picdir}/snapshot$(($i+1)).png
  6. convert -thumbnail 100x100 ${picdir}/snapshot$(($i+1)).png \
  7.         ${picdir}/thumbs/snapshot$(($i+1)).thumb.png

I have them bound to Ctrl+PrtScn and PrtScn, respectively. If you want to also automagically upload the file to a server and put its url into the clipboard (the middle click buffer), stick this at the end of the file:

  1. ftp -n -i <<END
  2. open ftp.example.org
  3. user username password
  4. cd blah/blah/blah
  5. put ${picdir}/snapshot$(($i+1)).png snapshot$(($i+1)).png
  6. close
  7. bye
  8. END
  9. xsel -c
  10. echo "http://example.org/blah/blah/blah$(($i+1)).png" | xsel -b

Should I be doing this?

This could actually be done in one line, but that line would be much longer than my screen is wide.

  1. adjacent = [i for i in self.points if abs(point.x-i.x) < 0.1 and abs(point.y-i.y) < 0.1]
  2. close_vert = [i for i in adjacent if abs(point.z-i.z) < self.thresh]

It just feels like I'm cheating.

I have quantum postfix

Does that mean it's running and not taking up any cycles?

  1. tron@compy:~$ sudo postfix start
  2. postfix/postfix-script: fatal: the Postfix mail system is already running
  3. tron@compy:~$ sudo postfix stop
  4. postfix/postfix-script: fatal: the Postfix mail system is not running

Make me a sandwich

xkcd has forced my hand. A quick search revealed that this is apparently the best way to check for superuser privileges. Go figure.

  1. sandwich.:
  2.         @[ -w /etc/shadow ] && echo "Okay" || echo "What? Make it yourself."
  3. a:
  4.         @:
  5. me:
  6.         @: