Akom's Tech Ruminations

Various tech outbursts - code and solutions to practical problems

Linux Figuring out the card number of a cheap SAA7130 capture card

Posted by Admin • Sunday, June 19. 2011 • Category: Linux
So you bought yourself a cheap Philips SAA7130 (or SAA713X or SAA7134) capture card to record motion, you plugged it in and you are getting a black or grey screen. Looking in dmesg you see the famous saa7134[0]: Huh, no eeprom present (err=-5)? And
saa7134: Congratulations! Your TV card vendor saved a few saa7134: cents for a eeprom, thus your pci board has no saa7134: subsystem ID and I can't identify it automatically saa7134: I feel better now. Ok, here are the good news: saa7134: You can use the card= insmod option to specify saa7134: which board do you have. The list:
What do you do? How do you try 175 card numbers and figure out which one works? Write a script!

Continue reading "Figuring out the card number of a cheap SAA7130 capture card"

Code and Hacks Migrating one Gmail account to another

Posted by Admin • Friday, May 13. 2011 • Category: Code and Hacks
I have a setup where a Google Apps Premier account is used for the active employees, but when they quit I want to archive all their mail but free up a paid user account for the next employee. We archive mail in a different domain, also on google apps - a standard edition, free. For a while now I've gone through a variety of ways of copying the mailboxes from one place to the other, and each approach was either partial, unreliable, or too time-consuming.

So I think I've finally settled on a viable approach that is neither.

Continue reading "Migrating one Gmail account to another"

Hardware Hacks Setting the date/time on the Mini Keychain Spy Camcorder

Posted by Admin • Monday, April 25. 2011 • Category: Hardware Hacks
Keychain Camcorder
The instructions that come with this little gadget are priceless in their verbatim Chinese glory, but are not helpful in their vague "Leave the details as an exercise for the reader" approach.

Here are the exact detailed steps to actually set the clock

Continue reading "Setting the date/time on the Mini Keychain Spy Camcorder"

Linux Backing up cPanel without hitting logout

Posted by Admin • Thursday, April 21. 2011 • Category: Linux
cPanel based hosting presents some challenges for automatic backups - there isn't an automatic way of creating local backups or any standard way of triggering their creation remotely. Numerous scripts exist yet none were quite the solution I was looking for - I am primarily interested in the databases and mail forwarders, though files wouldn't hurt either. Moreover - you can do this in a single line!

My Goal therefore is: Create and retrieve backups nightly. I don't want cPanel to push files to my off-site box, I'd rather initiate everything remotely and not have to open up access to some other system. cPanel does permit one to do this using a browser, hence it can be scripted. Really, scripting isn't even necessary - wget is all that is required! That said, I had a very hard time convincing wget not to visit the logout link on each page - once you log out, you're not getting anywhere anymore. So here is how I did it.

Continue reading "Backing up cPanel without hitting logout"

Linux MySQL replication dies with fatal error 1236: Client requested master to start replication from impossible position

Posted by Admin • Friday, February 4. 2011 • Category: Linux
This time, my master-master setup stopped replicating with no explanation at all - running START SLAVE yielded no warnings or errors. Inspecting the log yielded the aforementioned error (on Ubuntu, mysql logs to /var/log/syslog by default):
[ERROR] Error reading packet from server: Client requested master to start replication from impossible position ( server_errno=1236) [ERROR] Got fatal error 1236: 'Client requested master to start replication from impossible position' from master when reading data from binary log [4654]: 110204 10:09:20 [Note] Slave I/O thread exiting, read up to log 'mysqld-bin.000742', position 4274

So at first I thought this was a weird bug or a stunnel issue, but looking at 'mysqld-bin.000742' on the master it turns out that it's only 3980 bytes - position 4274 is indeed impossible. But how did it get this way?

Continue reading "MySQL replication dies with fatal error 1236: Client requested master to start replication from impossible position"

Code and Hacks The Eclipse, PDT and Smarty dance

Posted by Admin • Monday, January 24. 2011 • Category: Code and Hacks
Eclipse is a great developer tool, and I use mine for Java, PHP, and C++. It actually does all of the above really well, but when it comes to Smarty template Syntax Highlighting, it's a tale of much suffering. I honestly am not even asking for any Smarty auto-completion - just pretty colors that tell me when I'm fat-fingering the syntax.

Fortunately there is a solution that appears to work, and here is the currently valid step-by-step

Continue reading "The Eclipse, PDT and Smarty dance"

Linux Simple flat file site search in PHP/Smarty

Posted by Admin • Wednesday, January 19. 2011 • Category: Linux
Sometimes using a real search implementation (Lucene, Sphinx) is just too much. The particular site I was working on is something like 30 pages, it's maintained as flat files (Smarty templates, but it's basically HTML on disk), and it really, really should not require megabytes of code and cron jobs to be able to search it!

That said, this is a simple search solution - it makes a lot of assumptions:

Continue reading "Simple flat file site search in PHP/Smarty"

Linux Predictable ALSA numbering of USB sound cards

Posted by Admin • Wednesday, January 12. 2011 • Category: Linux
I have 3 rather cute Monoprice usb sound cards for use by mmpd (client I wrote for multiple mpd instances). The great thing about them is that for $9 you can just keep adding zones to your music systems. The bad news is, UDEV will reorder sound cards on boot as it pleases.

Zones changing would be survivable in itself (reboots are rare), but I also have a webcam and an onboard sound card that I don't use - so sometimes the numbers I've configured mpd to use aren't even valid sound cards! On to the continuing search for a working solution

Continue reading "Predictable ALSA numbering of USB sound cards"

Linux Fixing digitemp with LinkUSB on kernels after 2.6.32-24

Posted by Admin • Tuesday, January 11. 2011 • Category: Linux
As many people have discovered, kernels after 2.6.32-24 changed the USB-RS232 serial driver to not set hardware flow control (RTS/DTS) flags. No doubt there was a good reason. Unfortunately, digitemp and owfs don't enable it either, also probably for a good reason - at least when applied to older devices. What this means is that now when you try to use a LinkUSB (and probably other DS9097U type hardware behind USB to Serial converters), digitemp and owfs no longer work.

Let's apply a time-tested hackish approach.

Continue reading "Fixing digitemp with LinkUSB on kernels after 2.6.32-24"

Linux How to take down your pfSense firewall with one checkbox

Posted by Admin • Saturday, January 1. 2011 • Category: Linux
Simple: create a Traffic Shaper queue but forget to choose a queue parent.

Your firewall will not pass any packets across, and you'll have no idea what hit you.

Automotive Troubleshooting car heat issues or why stop-leak is a bad idea

Posted by Admin • Saturday, October 30. 2010 • Category: Automotive
I got my truck exactly a year ago. It came complete with stop-leak (the red brick-colored pellets) in the system. I immediately flushed out all coolant and stop-leak (must have run 100 gallons through the system with a back-flush kit), but I guess that wasn't enough, as I suddenly found myself without any heat whatsoever. Now I am not that into heat, but the idea of a sheet of ice on the windshield with no recourse just doesn't sound like fun.

Since I had to figure out what the issue was step-by-step, I figured I'd write the process down for posterity (read: me, next time). So here it is...

Continue reading "Troubleshooting car heat issues or why stop-leak is a bad idea"

Asterisk Asterisk and obfuscated SIP port redirection - calls drop after 20 seconds

Posted by Admin • Tuesday, October 5. 2010 • Category: Asterisk
One of my asterisk setups got attacked recently by a brute force script kiddie. The attack is simple:
  1. Try sequential sip usernames from 1 to 10000, hoping that the admin chose a numeric username scheme
  2. If asterisk returns anything but a 401, then perhaps this is a real account, add it to the list
  3. If anything is on the list of "possibles", then brute force their passwords


Why this works:
  • Asterisk has no delay for failed logins, so a brute force attack is viable, hundreds of attempts per second are possible. Not sure what can be done about this
  • The admin didn't set alwaysauthreject = yes in sip.conf. It's off by default, why??? With this enabled, there is no way to tell if a username is valid from the reject response


To deal with this:

Continue reading "Asterisk and obfuscated SIP port redirection - calls drop after 20 seconds"

Nvidia X Driver stops working in Ubuntu Lucid 10.04

Posted by Admin • Monday, July 26. 2010
In the hopes of fixing my periodic keyboard-gets-stuck issue, I upgraded to the latest and greatest kernel (2.6.32-24-generic), as suggested by the helpful Ubuntu upgrade tool. I should mention that the machine is a Dell Precision M4400 (it's a laptop, sort of). I was then greeted with a "Your display is messed up, you're in low-res mode" dialog. Running the nvidia configuration tool yields:

"You do not appear to be using the NVIDIA X driver. Please edit your X configuration file (just run `nvidia-xconfig` as root), and restart the X server."


Great. Now I'm down to one monitor. The nvidia driver won't load. Reinstalling it won't work. Setting this aside for a bit I attempt to start VirtualBox - and I get the same issue! - The kernel driver isn't loaded. OK so this must be a DKMS issue. I reinstall the virtualbox DKMS module:
 sudo apt-get remove virtualbox-ose-dkms
 sudo apt-get install virtualbox-ose-dkms


But that doesn't help, though it yields a hint: Kernel source is not available. Apparently the trusty ubuntu updater installed the new kernel but not the kernel headers for it! My Kernel is: uname -a
Linux akomgen3 2.6.32-24-generic #38-Ubuntu SMP Mon Jul 5 09:20:59 UTC 2010 x86_64 GNU/Linux
So:
sudo apt-get install linux-headers-2.6.32-24-generic
Now I can remove and reinstall the dkms packages for virtualbox and all the nvidia packages, and all is good again

Reviews Motorola Droid X Battery Life woes may not mean a defective battery

Posted by Admin • Monday, July 26. 2010 • Category: Reviews
Last week my wife replaced her Blackberry Storm2 (9550) with a shiny Droid X, and was relieved to find that the Droid kept up with her insane usage load just fine - whereas the Storm2 would lock up every few minutes (probably memory or garbage collection issues). That's the good news. Unfortunately, the X introduced a new problem - battery life. With her usage, it lasts 4 hours. The Storm2 lasted 24 or more. Granted it's a bigger display, but the specs promised ... well, a lot more than 4 hours.

We theorized that it may be runaway processes and excessive number of apps, or defective battery, but as it turns out it's neither. This is what I did:

Continue reading "Motorola Droid X Battery Life woes may not mean a defective battery"

Linux Verizon Wireless tethering Ubuntu Karmic to a Storm 2

Posted by Admin • Friday, April 2. 2010 • Category: Linux
This topic is fairly well described, so this is just a quick how to for me. (This is for USB, I am not attempting bluetooth this time) UPDATE: I now use berry4all instead of the below. It just works, and there is a GUI


Old Way:

  1. sudo apt-get install libbarry0 barry-util barrybackup-gui
    Chances are you already have the first two in a karmic install, and you may not even need barrybackup-gui. I did not need to add any new apt repositories
  2. if the phone requires a password, edit /etc/ppp/peers/barry-verizon and change the pty line to read
    pty "/usr/sbin/pppob -P My_Password"
    Yes there is a password line in that file, but it doesn't seem to do anything, and I don't know how to use variables in a pppd script :-)
  3. sudo pppd call barry-verizon
    You should see the progress and the IP's relevant to the connection. If you're having trouble, add debug:
    sudo pppd debug call barry-verizon
Note1: In my experience, after I kill the pppd connection I can't reconnect until I momentarily unplug the phone. Also, mass storage mode is not necessary.

Note2: These steps should be similar for most providers. Look at /etc/ppp/peers/barry-* to see the predefined provider scripts.

Note3: I believe that the connection will fail miserably if you have any other network connection active on the PC besides the tethered phone.

Note4: I am posting this using my blackberry!