Archive for the ‘Geek’ Category

(on Technorati , Del.icio.us)

Laptop’s New Life

My laptop has had its fair share of problems, mostly because it’s aging; I bought it nearly 6 years ago!! I’m actually impressed it’s aged so well! A few days ago, the display started to flicker with increasing frequency and become distorted shortly after turning it on. Here’s a video showing the problem: (Warning: contains a little bad language – woops…)

(Link to video here if embedded object doesn’t show up.)

Last night, I took it apart and tried wiggling every LCD-related wire I could find, hoping to affect the display’s output and conclude it was a fixable loose connection.

Laptop in Pieces

Nope. Fine. Who needs a screen anyway?

Screenless Laptop

I now have a very compact desktop – it even includes wireless, keyboard, mouse and speakers! It just needs a monitor. I haven’t decided whether I will make it a pseudo media PC to stream things from my desktop to the TV (a little work), or just to have it replace the family computer (almost no work!). The family usually gets my computer hand-me-downs. ๐Ÿ™‚

Anyway, looks like I’ll need a new laptop sometime soon. I vowed to go smaller with my next laptop, but I’m not sure if a netbook would suffice. Of course, I would like it to run Linux (Ubuntu?), have long battery life, reasonable storage, support WPA2, have a built-in 1.3MP camera, and all that good stuff. Bluetooth would be nice, too. Let me know if you have any suggestions.

Reading – XP and Design Patterns

I got a few books out from the library, recently, which I’ve been reading on the bus. I’m currently alternating between Extreme Programming Explained: Embrace Change and The Joy of Patterns: Using Patterns for Enterprise Development. I wish I had read the XP book before being project manager for my Software Engineering project at University, a couple years ago. But perhaps having gone through that experience allows me to relate to the material more directly. It’s easy to read and the author, Kent Beck (one of the fathers of XP), identifies the reasons behind the development methodology, and the problems they help solve. I’ve always had this feeling of agreement with XP practices, many of which seem like common sense, but haven’t always been able to articulate the reasons. Thankfully, the author does not have this problem. ๐Ÿ™‚ I’m about 50 pages in, and it’s quite good, so far.

I picked up the Design Patterns book because the one I wanted, Design Patterns: Elements of Reusable Object-Oriented Software, wasn’t there. (The library has 3 copies of it, but it’s always out with a wait-list of people requesting it. This list now includes me. ๐Ÿ™‚ ) Anyway, the one I picked up is extremely terse. There are UML diagrams provided, sample code, and a problem description… but not much in way of explanation. It’s format is kind of like this: there’s this problem, how do we address it? Boom, here’s a pattern. Boom, here’s a diagram. Done. Next. Or… but we could improve on this pattern with this other pattern. Boom, another diagram. Why? Figure it out.

This book is fine if you’ve been exposed to the patterns previously, and need a refresher, but it is not a good source to learn from. I’m familiar with some of the patterns, but even then, they may be called something different, or implemented slightly different, and it’s been a while, so it takes me longer to understand than if there was more explanation. Looking forward to picking up the other patterns book. If you have not been exposed to design patterns before, or are a relative beginner programmer, and definitely if you are not familiar with UML diagrams, avoid this book. It’s a book on design patterns (not a simple topic) that’s less than 200 pages, so you can’t really expect a thorough resource. I’m about half way through it. On one hand, I’m curious what such a small book has to offer, but on the other, I’m not sure I’ll finish it. I’ll probably concentrate on the XP book, for now.

2008 In Review

Life

This year has been pretty big. Naturally following up with lots of events from last year, these are some quick memories. My nephew, Rayden, was born on Feb 12th, six weeks early! This caused the father (my brother) to be indisposed for my dad’s (2nd) marriage on Feb 14th. I got bumped up to best man (but didn’t have to do much) and had a rather empty hotel room to myself in Vegas. I attended the Open Web Vancouver conference. I went to Whistler mountain for the first time in years and plan on going again soon. I went on a fantastic road trip down the west coast of the United States, something I will never forget. I slacked off most of the summer but managed to do quite a bit of rollerblading and outdoor activity hanging out with Kurt (visiting from Brazil). My brother, now a father, married the mother of his child on August 3rd. I was best man at this wedding, as well – with more responsibilities, but they were well received and totally worth it. Our beloved cat, Sky, met an early and terribly unfortunate end. We had our first encounter with bed bugs who are now the sworn enemy of our household. Vancouver, a city that sometimes doesn’t get snow all year, had its whitest Christmas ever with 60cm (2 ft) of snow! Perhaps we should have seen snow in April as a sign….?

That reminds me: Happy Holidays for 2008! Guess I was a little late on that… Here are some pictures of our insane weather in Vancouver.

Geekery

With my free time, I think I was able to really exercise my geekiness in 2008. I released a couple updates to the Rhythmbox Jump-to-Playing plugin, which led me to submit my first patch to an upstream project! Said patch was accepted and will be in the next version of Rhythmbox! Yay. ๐Ÿ™‚ It was just for some XML UI description, but it feels nice to have helped improve (even a tiny bit) a project that will be installed on thousands of computers in the next cycle. I also released a usable proof-of-concept GNOME Panel File List Applet which has stayed on my panel and I find quite useful. And I’ve done a couple little scripts and how-to’s that fall under the “nerd” category quite nicely. Oh yeah, and significant website updates. Next website todo item is to customize the attachment page for my theme, I think…. Also, I joined Twitter. And Identi.ca. And LinkedIn….

Art

Not many artsy things done this year. But with the significant improvements of tablet handling in Linux, I did some random doodles and a birthday card. I may not do it very often, but I still enjoy drawing, thank goodness.

Blog Stats for 2008

My Blog is by no means high traffic, but stats are fun! (These stats were obtained using the wordpress.com Stats plugin, and exclude the Feed stats, because I use Feedburner for that… although, I’m thinking I should revert that, now that I mostly use wordpress.com Stats.)

Top 3 Referrers:

  1. http://live.gnome.org/RhythmboxPlugins/ThirdParty (402)
  2. live.gnome.org/Boston2008/GUIHackfest (209)
  3. siuyee.com (126)

Top 3 Posts and Pages:

  1. Pidgin 2.1 UI Ideas (1,053)
  2. 2D Game Art and the Virtual Console (580)
  3. Rhythmbox Plugin: Jump to Playing 0.2 (455)

Top 3 Search Engine Terms:

  1. rhythmbox (327)
  2. bug (174)
  3. pidgin (165)

Top 3 Clicks:

  1. Pidgin UI screenshot attached to a bug (57)
  2. Pidgin UI mockup (50) by Hylke Bons
  3. SF2 HD Ken (42)
  4. The fourth was launchpad.net/desktopdrawers with 38 clicks, so it’s kinda cool I helped advertise a small project a little. (A project I’ve submitted patches to, no less. ๐Ÿ™‚ )

Thanks

Thank you, everyone, for a wonderful 2008. It’s been interesting, and despite a failing economy, I’m looking positively toward 2009.

Happy New Year! (????????????????) ๐Ÿ™‚

1024×768 Desktop

Lots of people customize their desktops. Many don’t, but I do.. a little. Here’s mine:

1024x768desktopusage_annotations

I actually had to remove the Time Tracker (Hamster) applet to scale my 1280×1024 desktop down to 1024, but I think that was all. And I only just decided to try moving the Tomboy and Deskbar applets over to the top-left corner… looks a little odd, but it’s much more accessible. It’s good to try out new things, right? ๐Ÿ™‚ (When the keyboard will do, Alt+F12 and Alt+F3 for Tomboy and Deskbar, and Super(windows-key)+Space for Gnome-Do are good shortcuts to keep in mind.)

How about you? (If you run Ubuntu, read this – which is why I tried scaling my 1280 desktop to a 1024, in the first place).

WordPress 2.7

I just upgraded from 2.6.3 (using my “wp-upgrade” script), and It’s fantastic! Go watch a video about the biggest features. It even includes an “automatic upgrade!!” This pretty much deprecates my script, unless you want to maintain snapshots of each version. (I’m not sure if anyone other than me was using it to begin with… but anyhow….) ๐Ÿ™‚

Screenshot: wp-upgrade Snapshots

Ubuntu 8.10 (Intrepid Ibex) and Tablets

I just had to mention this: The latest version of Ubuntu finally supports input hotplugging. What this means is that you can plug in your tablet at any point and start taking advantage of its pressure sensitivity, etc. Previously, it would only work correctly if Ubuntu (the X server part of it) started with the tablet plugged in. Let me just say: OMG, I’ve been waiting for this for years! Seriously. I hadn’t been keeping up with every detail on the release (and I’m surprised I hadn’t seen mention of this yet), but I always plug in my USB tablet and run a quick test with new releases. This time, it actually worked! My test turned into a quick (and random) doodle:

How to Test

Plug in your tablet.

Run GIMP (included with Ubuntu by default).
Applications > Graphics > GIMP Image Editor

Enable Extended Input devices in GIMP.
Edit > Preferences > Input Devices > Configure Extended Input Devices

Find your tablet under the Device dropdown (mine is a Wacom Graphire) and select Screen or Window for the Mode. (It defaults to disabled.)

Create a new image, select the paintbrush tool and start drawing. To play with the features of your tablet, expand the Brush Dynamics section in the paintbrush options window (should be below the toolbox, where you selected the paintbrush). Here you can adjust things that pressure of your pen will control, like size and opacity. Fun stuff!

It’s not perfect (only works with the stylus – eraser doesn’t work without configuring), but it’s a HUGE step!! ๐Ÿ˜€ And the fact that this also includes the latest version of GIMP (2.6) makes this upgrade an absolute no-brainer for linux graphic-philes. ๐Ÿ™‚

I found the new UI in GIMP a little strange at first, because I became so accustomed to the old one, but it is much better.

Upgrade Problems

Related to the upgrade, I lost wireless connectivity with my laptop upon doing it because the hostap_cs driver is used. I forgot about this issue that I had with previous releases and my super-cheap 1000yen wireless card. Blacklisting the hostap_cs driver and forcing the orinoco_cs driver fixed my problem again. The lesson: the upgrade wasn’t perfect and it should never be assumed that they will be – please backup your stuff! But do do the upgrade! ๐Ÿ˜‰

open-with for the command-line

Update 2008/11/18: Use xargs ๐Ÿ˜›

Here’s a bash script that you can pipe output into and tell it to run a specific program with the output as arguments. I’ve named it open-with and placed it in my personal script directory: /home/steve/bin/. Look within the script at a couple of the examples for how to use it.

#!/bin/bash

PROG=`basename $0`

DESC="Read arguments from standard input and run a specified program
with them.  Meant to be used as output for a pipe."


USAGE="OUTPUT | $PROG \"PROGRAM-NAME [OPTIONS AND ARGUMENTS]\""

EXAMPLES="
# List (with details), all the files that include \"downloads\" in their name:
  find /home/ -iname \"*downloads*\" | $PROG \"ls -l\"

# Queue all AVI files in current directory in vlc:
  ls *.avi | $PROG vlc

# View all time-related icons with eye-of-gnome:
  find /usr/share/icons/gnome/ -iregex \".*[^mul]time.*\" | open-with eog
"

function Usage() {
  echo "DESCRIPTION: $DESC" ; echo
  echo "USAGE: $USAGE" ; echo
  echo -n "EXAMPLES: $EXAMPLES"
}

# Quick check to see it's being called correctly, if not, print Usage and exit
if [ ${#@} -ne 1 ]
then
	Usage
	exit
fi

files=()						# empty array
while read -r					# read from stdin
do
	files+=( "$REPLY" )			# add result of read to array
done

# assume $1 is a valid program
$1 "${files[@]}"				# pass arguments to specified program

Motivation

You’re sitting at the command line and have a list of images (in different locations) that you would like to browse. Most image viewers let you iterate over a set of images, but only within the same directory. What would be great is if they accepted input from stdin through a pipe!

$ cat my_list_of_images | my_image_viewer

I didn’t find anything that did that, but using the open-with script, you can do something similar:

$ cat my_list_of_images | open-with my_image_viewer


Browsing a select list of images is actually kind of nice. It’s like a playlist for your image viewer – a viewlist. ๐Ÿ™‚ Anyway, I’m sure there’s some problems with this script. Feel free to provide suggestions in the comments. But I certainly don’t want to look at it for a while….

I hate shell scripting

With a passion. It’s not a great surprise… many programmers do. I’m willing to go on record and state that I hate it even more than PERL programming. I rarely do it, and when I decide to try something that seems like it would be simple, it turns out taking forever due mostly to quirks. The rest of this post is a bit about how I went about writing this script, which ended up being mostly given to me by some #bash gurus on IRC. And it’s a bit of a rant.

Although not many GUI programs seem to accept stdin as input, most accept filenames as arguments:

$ eog image1.jpg image2.jpg image3.jpg "/home/steve/image seven.jpg"

So I figured I would just have to convert the list of images into an acceptable format: quoted, absolute filenames, separated by space. Doing this depends entirely on the format the list is currently in, but it’s likely a list of unquoted filenames separated by newlines:

/home/steve/image1.jpg
/home/steve/my images/wow.jpg
/tmp/anotherimage.png

For me, my test list looked like this:

/usr/share/icons/gnome/48x48/stock/generic/stock_timezone.png
/usr/share/icons/gnome/16x16/stock/generic/stock_timezone.png
/usr/share/icons/gnome/16x16/stock/generic/stock_timer.png
/usr/share/icons/gnome/16x16/stock/generic/stock_timer_stopped.png
/usr/share/icons/gnome/16x16/stock/form/stock_form-time-field.png
/usr/share/icons/gnome/24x24/stock/generic/stock_timezone.png
/usr/share/icons/gnome/24x24/stock/generic/stock_timer.png
/usr/share/icons/gnome/24x24/stock/generic/stock_timer_stopped.png
/usr/share/icons/gnome/24x24/stock/form/stock_form-time-field.png

I was looking for icons of clocks or representations of time, and I obtained that list using find:

$ find /usr/share/icons/gnome/ -iregex ".*[^mul]time.*"

So I can’t pipe it into my image viewer, but I can use the output as the command-line arguments if I change the newlines to spaces. find has an option for formatting the output which is perfect:

$ find /usr/share/icons/gnome/ -iregex ".*[^mul]time.*" -printf "'%p' "
'/usr/share/icons/gnome/48x48/stock/generic/stock_timezone.png' '/usr/share/icons/gnome/16x16/stock/generic/stock_timezone.png' '/usr/share/icons/gnome/16x16/stock/generic/stock_timer.png' '/usr/share/icons/gnome/16x16/stock/generic/stock_timer_stopped.png' '/usr/share/icons/gnome/16x16/stock/form/stock_form-time-field.png' '/usr/share/icons/gnome/24x24/stock/generic/stock_timezone.png' '/usr/share/icons/gnome/24x24/stock/generic/stock_timer.png' '/usr/share/icons/gnome/24x24/stock/generic/stock_timer_stopped.png' '/usr/share/icons/gnome/24x24/stock/form/stock_form-time-field.png' 

That’s great for me, because I’m using find. But not very useful if I’m not, so I wanted something more generic. Of course, there are many ways to do this, and again, I’m by no means a command-line guru. But here’s how I started:

$ find /usr/share/icons/gnome/ -iregex ".*[^mul]time.*" | sed -e 's/^/"/' | sed -e :a -e '$!N;s/\n/" /; ta' | tr '\n' '"'

This wrapped the lines in double-quotes and join them together with a space in between. The find command is the same as before, minus the formatting because that’s what I was trying to find an alternative to. The output of find is piped into sed, which adds a " at the beginning of each line. This output is then sent to another sed which replaces the newline character at the end of each line with a closing double-quote and a space, joining all lines into a single line. Finally, that output is piped into tr which replaces the one remaining newline with a final double-quote.

If the files don’t include spaces or other troublesome characters (mine didn’t), then you could get away with simply changing the newlines into spaces. But again, I wanted something generic.

$ find /usr/share/icons/gnome/ -iregex ".*[^mul]time.*" | tr '\n' ' '

Anyway, now that we have something that creates the desired input, we just have to wrap it in back-ticks and put the whole mess as the argument to the image viewer! In my case, I’m using eye-of-gnome (or eog).

$ eog `find /usr/share/icons/gnome/ -iregex ".*[^mul]time.*" | sed -e 's/^/"/' | sed -e :a -e '$!N;s/\n/" /; ta' | tr '\n' '"'`

Wait a second. That doesn’t actually work. Why not? Running the backtick contents by itself seemed to produce the correct output. Copying this output verbatim as arguments to eog worked as expected. The problem was that when the quoted arguments were manually entered on the command-line, bash (silently) escapes the filenames, removing the quotes, adding backslashes before space,s etc. But when the pipeline is wrapped in backticks, the result is not escaped, and eog complains about not being able to find files that begin with quotes. Fine. I was not about to write a bash “escape” script – something like that should already exist, right? And it should be built in to bash! Perhaps it’s even called “escape“. Well, if there exists such a built-in, I couldn’t find it. But I had to be going about this the wrong way. Heading over to IRC, it was kind of difficult to explain the problem, but ferret eventually gave me the meat of the script above:

files=(); while read -r; do files+=( "$REPLY" ); done < <(find /usr/share/icons/gnome/ -iregex ".*[^mul]time.*"); eog "${files[@]}"

It worked! I thanked him and began studying it. There were still a couple things I didn't understand:

  • Why two angle brackets with a space between them? I understand the first one is probably redirecting input, but I don't understand that one next to the opening parenthesis.
    Answer: The <(command) actually puts command's output in a temporary file and produces that filename. So <(command) becomes tempfile. (Thanks, kojiro.)
  • If I open some video or audio files in totem using open-with, there's an odd delay. Using vlc doesn't produce a delay, however.

And to think this was originally going to be a micro-blog post in Twitter and identi.ca. Wow. It's safe to say I still hate shell scripting. ๐Ÿ™‚

What I did today – Time Tracking with hamster-applet

In GNOMEe 2.24, hamster-applet will be included by default. When I use it, I love it. I should use it more often.

I should note that “laundry” is actually inclusive to other room-cleaning activities. ๐Ÿ™‚

Rhythmbox Plugin: Jump to Playing 0.3(.1)

Update 2012-01-29 – Deprecated:
Brief: This plugin has been deprecated. For future versions and updates, please go here.

Less Brief:If you’re using a newer version of Rhythmbox, you’ll need a newer version of this plugin. I’m not sure exactly which RB version the plugin format changed, but I am currently using Rhythmbox 2.90.1 on Ubuntu 11.10 and this plugin no longer works. However, Timo Loewe has ported jump-to-playing to Rhythmbox 3, all properly hosted and everything! Get it and any future updates here (https://github.com/dmo60/JumpToPlaying). This is the version I’m now using. Thanks, Timo! ๐Ÿ˜€

– – – – –

The following pertains to the deprecated version of the plugin…

– – – – –

This plugin will display the View : Jump to Playing Song link as a button in the toolbar and/or as link in the Browserโ€™s context menu. Other Rhythmbox plugins can be found here.

Screenshots


Using a future version of Rhythmbox – patch here – the menu item will appear in a plugin placeholder, above Properties. Otherwise, it will appear at the bottom, like previous versions.


From version 0.3, the Open Folder plugin will also be placed in the plugin placeholder.

Changes Since 0.2

Just a couple small changes since 0.2.

  • Selecting the context menu option in the preferences will now display the link in PodcastView and PlaylistView popups, as well as BrowserView and QueuePlaylistView.
  • Assuming the patch on bug 557152 is applied, this will place the context menu items in a plugin placeholder and allow the Preferences to remain the last menu item.
  • Update (Nov 10 2008): Modified version of patch has been applied to RB development trunk, so the next version of Rhythmbox will have this update. Yay! Version 0.3.1 of jump-to-playing is to account for the modifications. Please use it. ๐Ÿ™‚

Download

jump-to-playing-0.3.tar.gz jump-to-playing-0.3.1.tar.gz
Browse the Source: Here
Grab the Source: bzr branch "http://stevenbrown.ca/src/jump-to-playing/"

Installation

  1. Extract the jump-to-playing folder into your ~/.gnome2/rhythmbox/plugins/ directory (or ~/.local/share/rhythmbox/plugins/ directory, if the .gnome2 directory doesn’t exist). Completely replace any previous versions.
  2. (Re)Start Rhythmbox and enable the plugin in Edit : Plugins.

Todo

From my previous post.

  • the gconf keys in gconf-editor say they have no schema. The main pluginsโ€™ keys have a schema and donโ€™t give a warning. Definitely not serious, though.
  • it currently adds/removes the ui string when the options are toggled in the configure dialog. I have a feeling it might be better to only add/remove them in the activation/deactivation, and just hide/show here. Maybe faster?
  • it currently hides the browser button in small display mode. That has nothing to do with the jump-to-playing button. That should be in core, if it was decided that was the desired behaviour.
  • to hide the buttons in the small display, it checks the value at activation, and it connects to the View menuโ€™s toggleButtonโ€™s โ€œtoggledโ€ signal. So whenever itโ€™s toggled, the gconf value for the small display mode is checked, but I think thereโ€™s a delay sometimes. Pushing Ctrl D quickly a few times may result in incorrect UI presented. I remember deciding that this is due to a delay set on the gconf callback to overcome some other bugโ€ฆ.

All patches are welcome! ๐Ÿ™‚

Update 2008/10/26: Added screenshot, descriptions to screenshots, and link to main plugin page.

Update 2008/11/10: Added link to version 0.3.1 and added description.

Update 2010/12/08: Added alternative installation directory.

Jump-to-Playing Rhythmbox Plugin TODO

I haven’t looked at the plugin for a while, but I’ve been meaning to reproduce my “todo” list for it that I wrote on the rb-dev list a while back.

  • the gconf keys in gconf-editor say they have no schema. The main plugins’ keys have a schema and don’t give a warning. Definitely not serious, though.
  • it currently adds/removes the ui string when the options are toggled in the configure dialog. I have a feeling it might be better to only add/remove them in the activation/deactivation, and just hide/show here. Maybe faster?
  • it currently hides the browser button in small display mode. That has nothing to do with the jump-to-playing button. That should be in core, if it was decided that was the desired behaviour.
  • to hide the buttons in the small display, it checks the value at activation, and it connects to the View menu’s toggleButton’s “toggled” signal. So whenever it’s toggled, the gconf value for the small display mode is checked, but I think there’s a delay sometimes. Pushing Ctrl D quickly a few times may result in incorrect UI presented. I remember deciding that this is due to a delay set on the gconf callback to overcome some other bug….
  • in the context menus, ‘Properties’ should really be the last item. They need a placeholder put in the UI core. UPDATE: I’ve filed a bug with a patch attached here. Jump-to-Playing and other plugins will need to be updated when the patch is applied. I’ve just done it on my local copy w/Rhythmbox HEAD…. Looks like this:
    Before (red) and After (green) applying the patch and using an updated plugin

    Before (red) and After (green) applying the patch and using an updated plugin

  • Show the context menu item in PodcastView and PlaylistView popups, as well. I’ve added this in my local copy, already. Maybe I should just bump the version and release….