Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

Linux Getting Pidgin to sign off when you lock your screen

Posted by Admin • Wednesday, October 14. 2009 • Category: Linux
I am signed in to google talk from many places - blackberry, laptops, desktops, etc - and every once in a while, IM's don't go to the right one. Since I lock my workstation at the office whenever I get up, I figured it'd be nice to have Pidgin log off at the same time.

I am not sure how you would do this in Windows, but in Linux (Ubuntu in my case), I did it like this:

Changed my screen lock hotkey (Ctrl-Alt-l for me) to run the following:
xlock -startCmd "purple-remote setstatus?status=offline" -endCmd "purple-remote setstatus?status=available"
That's it. If you want specific screensaver modes you can stick them in them too:
xlock -mode blank -startCmd "purple-remote setstatus?status=offline" -endCmd "purple-remote setstatus?status=available"

Update: July 2012

Ubuntu has a broken version of xlock (1:5.31-1) which gets the BadMatch (invalid parameter attributes) error. I switched to using slock from "suckless-tools" package, like so:
bash -c "purple-remote setstatus?status=offline ; slock ; purple-remote setstatus?status=available"

Interestingly, after running slock, xlock works too.. it's actually related to dpms: If you run xset +dpms, xlock will work (once).
You can adjust the xlock version for this bug as follows:
xlock -mode blank -startCmd "xset +dpms ; purple-remote setstatus?status=offline" -endCmd "purple-remote setstatus?status=available"

PS: Doing this in openbox:

<keybind key="C-A-l">
        <action name="Execute">
                <command>xlock -startCmd "purple-remote setstatus?status=offline" -endCmd "purple-remote setstatus?status=available"</command>

Linux Fixing freezing and no sound youtube and flash on ubuntu

Posted by Admin • Monday, September 28. 2009 • Category: Linux


I've had this issue for many months but obviously I don't use flash enough to really figure it out. The first few youtube videos would play, but with no sound. If you seek back and forth, or play sound from another player (eg audacious), you may get skipping sound for a little while. Eventually the whole player stops advancing, though you can still seek.


  • You may have installed a dozen version of flash by now. As long as they are all ubuntu packages, you can leave them all installed (or you can remove them all)
  • Install the official release from adobe: Adobe Flash, current version is 10. Pick .deb format for the download.
  • Now run sudo update-alternatives --all
    ... This will ask you for all alternatives there are for your system, but among them there will be 5-10 flash-related questions for each browser (including text browsers, apparently). Pick the newly installed adobe-flashplugin like so:
      There are 2 alternatives which provide `mozilla-flashplugin'.
      Selection    Alternative
    *+        1    /usr/lib/flashplugin-installer/libflashplayer.so
              2    /usr/lib/adobe-flashplugin/libflashplayer.so
    Press enter to keep the default[*], or type selection number: 2
  • Bounce Firefox and you should be all set

    • Software Mixing

      Once I got this fixed up, I now had reliable flash playback with one little problem... There was still no sound half the time - if another audio application grabbed my sound card before firefox (eg rhythmbox). Took me a while to figure out what to search for (usually the biggest issue, right?). Apparently the issue is twofold:
      1. My onboard sound card either doesn't do hardware mixing, or the drivers don't support that
      2. Alsa should have figured that out, and turned on Software Mixing, but for some reason it doesn't do that in Ubuntu
      Once I understood this, I used This page to help me out. Grabbed their ~/.asoundrc, restarted all the audio apps, and all seem to be sharing the sound card peacefully now.

Code and Hacks Locked myself out of pfSense

Posted by Admin • Saturday, September 26. 2009 • Category: Code and Hacks
I was experimenting a bit with pfSense 1.2.3rc1 as a replacement for a WRT54G router today.
So I set did the following, among many things:
  1. Switched web configurator to SSL (443)
  2. Turned on reflection (applies NAT port forwarding rules to local LAN)
  3. Set up NAT port forwarding, which includes port 443 to one of my servers (which isn't up at the moment)

Guess what? Can't access webconfigurator.... an hour of being very confused later... I get it. All my SSL requests for webconfigurator are now being sent to the nonexistent internal NAT-ed server! I can't get back in, and reboots don't help!

Fixing this is not too hard. Log in (SSH or console) and edit /conf/config.xml

Now just change to http. (If you're not running off hard drive, you may need to save directly to your floppy.) Obviously changing this will prevent you from using reflection from a NAT-ed server on port 80 now :-)

NOTE: you may need to "rm /tmp/config.cache" to clear out config cache, and restart web configurator from the menu.

Reviews The Valor ITS-301D DVD/CD/MP3/MP4/etc car head unit

Posted by Admin • Tuesday, September 8. 2009 • Category: Reviews
I recently bought a truck to replace the conversion van as a tow vehicle, and decided not to move the Innovatek head unit from the van to save myself some hassle. This gave me an opportunity to try out a new device as I was somewhat frustrated with the Innovatek (see review). I was looking for basically the same exact thing, but one that worked, well, better. Oh and of course having a TV tuner is no longer of any value.

I can spoil the suspense by saying that the Valor ITS-301D proved to be an improvement and I have only positive things to say about it. Some details:

Continue reading "The Valor ITS-301D DVD/CD/MP3/MP4/etc car head unit"

RV Getting RV Solar and Shore power to coexist nicely

Posted by Admin • Tuesday, August 4. 2009 • Category: RV
I have an RV (20' Sunline T1950 travel trailer) Yay! Like most, it came with a tiny battery (23Ah @2.5hour rate??) and a Power Converter (Centurion 3000) which doubles as a battery charger, but it's hardly a good one - it's not even a 1-stage (that would be just bulk charge) - instead it is a float-only 13.1V power supply. Charging a sizeable battery using a float charger would take a very, very long time (and is hardly good for the battery). According to documentation it's supposed to output 13.4V but I guess it's +/- 0.5V :-)

My primary interest is in boondocking (dry camping) so for me battery performance is of utmost importance. This means good battery utilization, and good battery charging when charging can occur. Stock, the RV does neither.

First thing I managed to do was to secure a small solar system including a Solar Charge Controller (got an awesome deal on Craigslist). It's 100 watts and the CC is a 2 stage (absorption and pulse-float), 15 Amp unit (Mark PV 15). My first question was of course... how do I hook it up to the existing electrical system without causing problems?

Continue reading "Getting RV Solar and Shore power to coexist nicely"

Low Tech Hacks Installing two cameras in one vehicle (rear view) with one display

Posted by Admin • Monday, July 27. 2009 • Category: Low Tech Hacks
Now that I acquired a travel trailer, it was a matter of utmost importance to install a rear view camera on it to ease the process of backing it up. I already have a rear view camera on my van, hooked up to my head unit which happens to have a rear camera input. So the next question is - how do I hook up two camera?

I don't want to give up the one I use all the time in favor of the occasionally used trailer cam. What am I to do? So I had to figure it out.

Continue reading "Installing two cameras in one vehicle (rear view) with one display"

Low Tech Hacks Changing Manual Transmission Fluid in a Scion tC

Posted by Admin • Saturday, April 11. 2009 • Category: Low Tech Hacks
The goal is to replace the stock (assumed: mineral oil) transmission fluid with Amsoil synthetic. Amsoil is my personal preference, while synthetic is my maintenance goal. I set out to do this as our vehicle was approaching 60K miles... OK so I meant to do this about 60K miles ago, but better late than never. The car is now 3 years old (exactly).

There isn't anything too difficult about this job, but when I got under the car I discovered a filler bolt labelled "Consult Owners Manual Before Refilling"... now I've done a fair share of work, but this looked suspicious. So I set out to investigate.

Continue reading "Changing Manual Transmission Fluid in a Scion tC"

Code and Hacks Creating A Basic Date Dimension Table in MySQL

Posted by Admin • Monday, March 23. 2009 • Category: Code and Hacks
After some searching I determined that nobody wants to share ...

So I had to sort it out myself - the result is a pretty basic stored procedure you can call whenever you like.

Continue reading "Creating A Basic Date Dimension Table in MySQL"

Code and Hacks Turning the Iphone 3G into an almost useful always-on IM device

Posted by Admin • Saturday, March 14. 2009 • Category: Code and Hacks
I've had a Blackberry for quite some time now, and came to take for granted the basic ability to be always available via Google Talk, Latitude, email, etc - not to mention have fine-grained control of when I get notified about each one. Running multiple apps (gtalk, maps, ssh, browsers, etc) - was never a problem, and there is even an Alt-Tab equivalent for toggling between running apps. Blackberry even has an integrated push-IM system for Blackberry to Blackberry communication.

All that changed with the IPhone (if it was not paid for, I would never have gotten one, but now I'm trying to make the most of it while saving the money I used to spend on the Blackberry). The IPhone (3G, 2.2.1) proved to be unable to do any of the above well. No mail alerting rules, no running multiple applications !!?? Basically this is an always-on device that cannot provide most always-on services. So this is my quest to make the device useful.

Yes naturally I realize that there are downsides to both devices, and I gladly give credit to the IPhone UI, but personally I'd rather deal with a command-line UI if I had to choose between functionality and having a fancy but incapable toy.

Continue reading "Turning the Iphone 3G into an almost useful always-on IM device"

Asterisk My Not So Great Experience with Grandstream HT-502 ATA

Posted by Admin • Friday, March 13. 2009 • Category: Asterisk
I got 3 of these Grandstream HT-502's for a client's Asterisk setup, and I picked Grandstream basically because they were cheap (client on a budget) and I found no bad reviews. They were ordered February 2009.

First impressions: They are tiny, like two EZ-Passes stacked on top of each other. They are cute, and have all the features you'd expect or even desire in such a device: Dual WAN (routed or bridged, with port forwarding), two FXS ports, some status LEDs, remote configuration and pull provisioning, syslog support, etc.

Well that was the good news...

Continue reading "My Not So Great Experience with Grandstream HT-502 ATA"

Code and Hacks MySQL Master-Master Replication over a Secure Stunnel Connection (SSL)

Posted by Admin • Saturday, February 7. 2009 • Category: Code and Hacks
I threw this together because I had to figure it out myself. I found info on how to setup master-master, and I found info on how to set up MySQL replication over stunnel. But master-master over stunnel turned out to be a little different. Not much, but here it is.

First of all - I won't go into the steps for setting up Master-Master itself - that's very well documented. Let's assume that you can convince one of your mysql's to slave off the other, and vice versa. (I used this page as a guide).

With that accomplished, let's assume that the boxes are not sitting next to each other but are in separate colo's or offices, and have some insecure internet to go between them (or maybe you don't even trust the local LAN). Yes, MySQL does have built-in SSL stuff, but so far the consensus is that it's rather difficult to work with. Moreover, I am more willing to trust stunnel (just my feeling on it).

Why not use ssh? Using something like ssh -n with a for loop that restarts it just doesn't sound enterprise-grade. I want something that actively reconnects when needed, based on active usage, and is actually intended for this. I still use SSH for port tunnelling all the time, but those are short-lived tunnels for my own personal use or debugging.

So our goals are: Secure transport and identity validation. Here we go.

Continue reading "MySQL Master-Master Replication over a Secure Stunnel Connection (SSL)"

Asterisk Data Warehousing and Metrics with Asterisk PBX

Posted by Admin • Sunday, February 1. 2009 • Category: Asterisk
An Asterisk installation I am doing for a client has the promise of two interesting developments in the near future:

  1. Writing a CDR/Voicemail status-tracking application that makes sure that all client voicemails are handled within one hour and keeps track of what was done
  2. A future custom metrics/data warehouse implementation that will use both the CDR and VoiceMail data

With that in mind (and the fact that I'm using Mysql master-master replication across offices) I looked into storing the voicemails in the database as well. This is fairly well-documented. I had this up and running in no time, and now for each voicemail I have a neat row in my MySQL table.

The problem is - how do I connect the row in CDR table to the matching voicemail row? There are no columns that have data to allow you to do match one to the other. Even timestamps, if you were so desperate, are not exactly the same! So this is how I did it.

Continue reading "Data Warehousing and Metrics with Asterisk PBX"

Low Tech Hacks Getting your refrigerator to run without a start relay while you wait for the part

Posted by Admin • Monday, January 19. 2009 • Category: Low Tech Hacks
It took me 24 hours to notice that my Maytag top-freezer refrigerator (PTB2454GR) stopped cooling. (OK the puddle on the floor helped me notice). When it started (Saturday morning, I think), there was a click, 10 seconds of buzzing, then silence. This would repeat every 2-3 minutes. I didn't think much of it, thinking it's the ice maker acting weird. What I should have noticed was the complete absence of compressor noise - just the fan. Actually, there wasn't even that noise - it was silent.

I eventually figured out that the start relay (if you can even call it that) needs replacement, but that was not the initial problem - the problem, as it turned out, was one packing peanut. Yeah, one peanut - it got stuck in the Condenser Fan, literally preventing it from running. This in turn probably caused ice buildup, or in some other way increased the compressor load, which in turn finished off the start relay. Frankly, I'm not sure how long the peanut was in there - may have been months, or maybe just a day.

So if you're seeing similar behaviour (see first paragraph), these are the steps to troubleshoot and temporarily remedy the situation (Disclaimer: there is a very good chance of electrocuting yourself in the process, as with any high voltage appliance). I have a little wiring diagram that explains what and why in here as well.

Continue reading "Getting your refrigerator to run without a start relay while you wait for the part"

Asterisk Teaching your Asterisk phone system to control your music

Posted by Admin • Saturday, January 17. 2009 • Category: Asterisk
Ever since I built my Asterisk-based VOIP phone system I've been finding more and more interesting ways to put it to work. I mean, it's a business phone server, but it's got plenty of resources as it sits around waiting for a phone call. So I figured... why not be able to pick up the nearest phone, dial an extension, and be able to stop/start/skip my whole-house music? How about doing this from anywhere? OK this may seem odd to you, but you'd be surprised how often it saves you from having to get up and go find the remote or having to wake up a computer :-). OK you're not convinced that this is very useful. How about pausing music for a phone call? Automatically?

For those who don't know, Asterisk is a open source (and free) software PBX system. You know, the thing that IP phones connect to (you know, that little box you got from Vonage - it connects to something - well in my house, it connects to my server). It provides call routing and management, voicemail, IVR (menus), etc. In short, it's awesome. I mean, yeah, it's a little unintuitive at first, but it's not that complicated once you loosen up your old fixed programmatic thinking a little :-)

So, here is the setup.

Continue reading "Teaching your Asterisk phone system to control your music"

Reviews Aliph Jawbone 2 overheats and nearly burns fingers, melts internally

Posted by Admin • Wednesday, January 14. 2009 • Category: Reviews
Got a shiny new Jawbone 2 from Buy.com the other day, and this is my experience with it over 2 weeks, ending in its eventual return. This also details my experience with Aliph Customer Service.

Initial pairing: I missed the "I am in pairing mode the first time I'm turned on" window, apparently - and getting it to go into pairing mode by holding the two buttons down took at least 20 tries. (seriously) In retrospect, I'm glad that it isn't so easy to put into pairing mode - I might do that inadvertently... But it worked, and boy did it work well. We tested it with a Shark cordless vacuum in hand, and the other person could only vaguely tell that there may be something making noise in the background. With NoiseAssasin disabled, you could hear the vacuum cleaner clearly instead of the person.

All was well, until...

Continue reading "Aliph Jawbone 2 overheats and nearly burns fingers, melts internally"