Archive for the ‘hacks’ Category

Access -> MySQL

Friday, October 23rd, 2009

Long, long ago I hacked together a Java app that imports the freedb CD info files from my local drive to an MS Access database. The CD ripper application I use creates a local freedb with a file for each CD I rip (all of them). So importing from that freedb to a database seemed a natural thing to do.

Access was all that I had access (heh) to, and it had a “music collection” database template, so with slight modification to the template that’s what I used.

Well now, I no longer have access (heh) to Access, Access is a PITA, and I already have MySQL available on my home server, so I figured it was time to finally migrate.

I found a handy application called Navicat (fully functional trial), that will import directly from the Access .MDB file to a MySQL database.

While Navicat mostly worked, I was not quite done. The import did not properly get the auto_increment attribute on the tables’ ‘id’ column. Also, the Access database tables had spaces in their names which is kind of a drag. Fortunately both were easily solved by exporting from MySQL to text using mysqldump, editing the .sql file that resulted, and then reimporting to MySQL from the .sql file.

Sure it’s a ridiculous thing nobody in their right mind will ever have to do, but I’m not in my right mind.

DIY headset locker for Rock Shox Pike

Tuesday, May 19th, 2009

This might work for other Rock Shox forks too…

My new Pike’s steerer tube has a cap in the bottom with a threaded hole the same size as a standard headset bolt (M6). Instead of pounding a star nut into the steerer, it’s exteremely easy use this cap as the bottom of a headset locker like the Azonic Headlock or USE Safe-T.

Required parts (in addition to headset, stem, spacers, etc.):
M6 threaded rod (shortest I could buy was 3 feet)
M6 coupler nut
Total cost about $5.

Insert the rod to measure the correct length. I threaded the rod through the bottom of the steerer tube until half an inch or so was protruding out the top of the tube. This took some time to thread the 10″ of rod through; I could have done an initial cut to an estimation of length to save myself some time, I suppose.
img_1182
img_1181

Add coupler nut, headset cap and original stem bolt. Thread the nut on the rod first, headset cap on original stem bolt, and then stem bolt into the coupler nut as well.
img_1183
img_1184

Tighten down the headset cap so there is no play or extra space in the steerer stack. Mark the point where the rod emerges from the bottom of the steerer tube. Take it all apart again, and cut the rod at the mark with a hacksaw.
img_1185
img_1186

Put it all together with the headset cap back on original bolt, coupler to original bolt, then threaded rod into coupler. You may want to use some removable threadlocker on the coupler to make it behave more like a single bolt when it’s in the steerer. Tighten the original stem bolt tightly into the coupler; it’ll butt up against the threaded rod.
img_1188
Drop the whole thing into the steerer tube, thread it into the bottom cap, then tighten the bolt to the torque specs of your headset.

Follow my TiVo on Twitter

Tuesday, February 24th, 2009

The other night my friend Bob mentioned somebody had set up a Twitter account for their TiVo. After thinking about it for a second I said something like “that’s almost trivial”.

Naturally I had to see if it really was trivial, which in fact it turned out to be. @mrbalkytivo is busier than I am.

Put tweetTivo.php someplace to be called by cron.

class_tivo_xml.php is not written by me and is required. Google it up. Figuring out how to get the XML info from the TiVo is left as an exercise for the reader.

The script will tweet about any new recording that starts, including TiVo suggestions, which are not always reflective of my taste, but then again, neither are many of MrsBalky’s choices. I thought about enhancing the script to skip suggestions, but grew bored and drifted away.

TwitPic upload hack

Tuesday, January 13th, 2009

Some Twitter users have been using TwitPic to link photos to tweets. I, on the other hand, have been using Flickr and Snipr. It’s a PITA, so I’m giving TwitPic a whirl. Sadly, Digsby, does not support TwitPic, and I’m not installing yet another app.

TwitPic has an API, so I rolled my own simple uploader with cygwin and curl. There’s no doubt in my mind that I’ve reinvented the wheel here…

Standard disclaimer applies: this is quick n’ dirty(tm):

#!/bin/bash

# curl executable.  I'm a PC.
CURL=C:/cygwin/bin/curl

# The upload script that will accept the data
UPLOAD_URL=http://twitpic.com/api/uploadAndPost

# Snag stuff off the command line
TWITTER_USER=$1
TWITTER_PW=$2
PHOTO=`cygpath -m "$3"`
TWEET_MSG=$4

# Prompt for message if it's not given
if [ "$TWEET_MSG" = "" ]; then
   read -p "Tweet msg: " TWEET_MSG
fi

# Go
echo Uploading...
$CURL \
  --form username=$TWITTER_USER \
  --form password=$TWITTER_PW \
  --form media=@"$PHOTO" \
  --form message="$TWEET_MSG" $UPLOAD_URL

# Wait for user to read result message
echo
read -p "Press <enter> to continue" bogus

Create a desktop shortcut with uid and password:

C:\cygwin\bin\sh.exe ~/twitpic.sh --userid-- --password--

Now just drag and drop the photo onto the desktop shortcut.

Hate the iGoogle left-side navigation?

Friday, December 12th, 2008

Hate that it takes up screen real estate for no reason? Find Gmail canvas view as unusable as I do?

Check out all that unused grey space:
igoogle
The last straw for me today was to discover that they put chat in the navigation bar, and it was impossible to turn off. I found a groups forum thread where I could actually register my discontent, and found this little gem:

http://www.google.com/ig?hl=all

Add that “?hl=all” to the end of the URL, and hooray! Tabs on top again!

Some things you do just because you can

Friday, October 24th, 2008

Need another Sonos controller?

Hack together openlink, perl, sonosweb and iphone sonos:

I had to go through Perl dependency hell (Perl really is an abomination) to get sonosweb working on the linkstation, but it works pretty well now.

Throw in a little DD-WRT and ssh and you can really mess with your S.O. by changing the music at home from the office.

Now I need to write up how I got through the seven circles of dependency hell before I forget. It took more than a quarter to Charon.

What to do when iTunes hoses your USB port

Friday, May 2nd, 2008

For whatever reason, iTunes sometimes just screws up the the USB device I plug my iPod into. It’s toast, and no device will work; not the iPod, not a flash drive, nothing. No amount of being careful with iTunes and “ejecting” the iPod will help.

Rebooting the computer fixes it, but this happens with such regularity I’d be rebooting several times a day.

But I discovered that if you disable the USB port/device, and then enable it again, the problem is also fixed. Going through the device management dialogs is incredibly cumbersome, so I wrote a script.

fixusb.bat:

@echo off
echo "disabling usb device..."
devcon disable "@USB\VID_0424&PID_2504\5&18F4DAC0&0&5"
echo.
echo "enabling usb device..."
devcon enable "@USB\VID_0424&PID_2504\5&18F4DAC0&0&5"
echo.
pause

The @USB\VID_... bit is the USB device ID. To get the device ID, you’ll have to go to the Device Manager dialog. Figure out which device the iPod is attached to (I don’t remember exactly how I did this; sorry). Then on the “Details” tab of the device “Properties” dialog you can get the “Device Instance Id”.

I have to use this all the time, so put a shortcut to it on the desktop.

Presta inflator on the cheap

Thursday, April 10th, 2008

One of the best things I got from my brother when he moved out of his huge house into a small apartment was his compressor. It’s amazing how useful air is.

So most bike tires these days have presta valves, which are not nearly so easy to deal with as schraeder valves like those on cars. There are adapters that sort of convert presta to schraeder, but they’re kind of a cumbersome, and I wanted something more convenient. Surfing around, I found a tool that does it commercially available for $50.

But since I already have a blower tool, and I’m terminally cheap, I decided to try build one for less.

Voila:
5.jpg

And just screwing around a little, I turned it into an Instructable.

Custom iPod Touch icon

Friday, January 18th, 2008

Thanks to a post over at Laughing Squid, bookmark MrBalky on your iPod Touch (or the less cool iPhone) and revel in the awesomeness:

itouch

Of course, everyone is doing it.

The TiVo widget

Wednesday, January 2nd, 2008

The TiVo now playing list has been a “feature” on the right-hand side of this blog for a couple years now.

Todd has been admiring it for his blog for some time, but the poor fellow only had Series 3 TiVos, which had networking features turned off so he couldn’t do the same. Now that TiVo has seen fit to turn that feature on in the S3s, I found I had to clean up the code so he could use it over on his blog.

As Todd says, sometimes you have to build things just because you can.