Tag Archives: Coding

TiVo2Podcast update

It’s been a long time since I’ve put a new version of TiVo2Podcast out there for people to play with.  I’ve made a lot of changes and tightened things up alot.  There’s still a lot of things I want to do but haven’t gotten to, but I did finally put up a public git repository in case others wanted to join in the fun.

The major changes in this release:

  • Commercials are detected and chapters are added around them.
  • Added “clean up” functionality so that you can deleted unneeded files and the database and rss feeds can reflect that.
  • Increased the wait time for locating the tivo from 2 seconds to 5.
  • Fixed problem created by quotes in the show description.
  • Attempt to avoid re-encoding dupes by checking the program id.
  • Lost of behind the scenes refactoring.

The first item I consider a major enhancement, so I put it in italics.  To make that work, you’ll need to get wine, comskip, and build a helper app.  The documentation is in the hastily wrote README. (A reminder, this is intended for PERSONAL USE ONLY, do not set up podcast feeds and violate the ethics (and also the laws) of copyright left and right.)

As always, this has run daily for months and months on linux. It should work on other UNIXes just fine. On Windows, I have no idea.

Download: tivoscripts-20110123.tar.gz

Build libcurl as a universal binary

I release one of the projects from work as a universal binary on OS X.  Up until tomorrow that mean just i386 and ppc.  With snow leopard, it looks like it’ll be a good idea to support the 64-bit architectures as well, especially considering its an ODBC driver I’m working on and the native apps running at 64-bit will want to talk to it that way.

Since we used a lot of open source libraries to save us time, I need to have those built super-universal as well.  The first one I tackled was curl, which had some issues due to configure, so I had to write a shell script to do the hardwork for me.  It needs to run configure three times, and I got a lot of the information for it from http://curl.haxx.se/mail/lib-2009-05/0000.html.

#!/bin/sh
export CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -arch i386 -arch ppc"
./configure --prefix=/usr/local/encap/curl-7.19.6 --with-ssl=/usr --without-ca-bundle --disable-dependency-tracking

cp include/curl/curlbuild.h include/curl/curlbuild32.h

make distclean

export CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -arch x86_64 -arch ppc64"
./configure --prefix=/usr/local/encap/curl-7.19.6 --with-ssl=/usr --without-ca-bundle --disable-dependency-tracking

cp include/curl/curlbuild.h include/curl/curlbuild64.h

make distclean

export CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -arch i386 -arch ppc -arch x86_64 -arch ppc64"
./configure --prefix=/usr/local/encap/curl-7.19.6 --with-ssl=/usr --without-ca-bundle --disable-dependency-tracking

cat > include/curl/curlbuild.h <

There will be more of these as I build the other dependencies.

7 Things You Hate About Me

I’ve been meaning to do some blog posts, but I haven’t had the motivation.  It doesn’t help that I’ve also been distracted by all the video games I got the past week.  (More on those in a future post.)  In any case, I got some motivation in the case of being tagged by a meme.  Evo called me out and I guess I should respond.  By the way, I loved Evo’s #3 as I share a similar outlook/philosophy/happenstances.

This meme requires me to share seven facts about myself.  The hard part about this will be coming up with 7 facts that will be interesting to people not me.

  1. I too often accept things the way they are. This description will be mostly slanted in looking at myself as a pogrammer, but this is where I can identify it best.  On a day to day basis this acceptance often makes me feel stifiled in creativity due to my lack of skill in identifying problems.  I can come up with great and creative solutions, but actually finding the interesting problems to solve if difficult because I accept that’s how things are, and don’t find shortcuts/solutions/whatever to make them better.  Eric Raymond described that as the “itch” that drives programmers to create…  As a programmer, I’m not itchy enough.
  2. Beer snob: I iz one. To anyone who’s been reading this blog or watching my twitter feed this is not news.  Part of the blame lies with Jon Roma who introduced me to the good stuff first when I started drinking.  I never went down the good old fashion macrobrew route.  I’ve learned to tolerate the macrobrews so I can drink beer at ball games or social events when something better isn’t available, but its rough going.  I’m no Charlie the Beer Guy, but I’m working on being on his level.  I’m just too lazy right now to take up my own brewing.  Maybe once the kids are older.  In any case, give me a Duvel, something from Stone, Goose Island, etc.  Don’t offer me anything named Bud, Miller, etc.
    Bonus fact 2.5:  I didn’t start drinking until I was in my junior year of college at age 20.  Given that when most people think of me they think of beer, this is probably a surprising fact.
  3. At heart, I’m a Geek’s geek and I’ve come to accept it. A few months ago, I finally accepted If there is a stereotype for being a geek, I probably fit it.  Again, not news for those who have been playing along at home for awhile.  There are exceptions, but all in all, I’m a geek.  I full embrace the geekiness and let it wash over me.  There are much worse ways to view yourself so it works for me.  (Notable exception: I have never played any desktop roleplaying type games such as D&D.  Not sure why that never happened, but it didn’t.)
  4. Needles piercing my skin send me into panic attacks. Its weird, I don’t mind blood, I don’t mind seeing myself cut, and I don’t mind looking at needles, but knowing one is about to pierce my skin turns me into a sweaty little girl.  It doesn’t matter if its the dentist, a lab tech taking blood, or whatever, I get tense and sweaty.  When having blood drawn I’ve learned to mitigate the effects by getting them to take it while I’m lying down, but that’s about it.  If I’m sitting up, I’ll pass out.  Its probably an anticipating thing, but I’m okay when I get cut when doing yard work or making dinner or something like that, but know I’m about to get a needle stuck in just puts me over.  I’m not sure what the deal is.  I guess the good news is that this is yet another sign that I’ll never get addicted to heroin.
  5. I hate small talk. I just can’t stand it.  It could be that I’m just not very good at it and that’s why I don’t like it, but the whole idle chit chat thing does nothing for me.  I’m good and I look forward to actually connecting with people and having deeper discussions, but if I have nothing in common with someone, its very painful for me to try to force the small talk.  I am faced with the slight challenge of how do you know if you have something in common with someone without having the small talk, but there are ways around that and I get by okay so I don’t worry too much about it.
  6. I love presenting and educating if I know the material and/or have a story to tell with it.  One of the great things about my old job and my still-employeer was that on a more than monthly basis I was giving presentations to our members on subject matter I had down cold.  Once I know the “story” I want to tell to educate others I love putting the presentations together, guiding discussions around the material, and generally helping people see the light.  Nothing made me feel better than to see the look of realization and/or understanding on someone’s face.  Or the look of horror once someone realized that they’d have to change their ways to make something work for them, but that’s a different story…  Either way, it means the message got across.  Someone would say this somewhat contradicts #3, as geeks aren’t well known for being showman, but I’ve always had a bit of an extroverted streak in me.  I guess I’m only extroverted in the right circumstances…
  7. I watch way too much TV and my reading and video game playing suffer due to it.  Part of it is the young kids and the job that just leave me energyless at the end of the day, some of it is I just really like good TV.  Heck, I probably like shitty TV too, but I try to keep it on the good side with things Battlestar Galactica, CSI, and Lost.  But I do have the mindless popcorn like Eureka and How I Met Your Mother.  I’m not sure where to put Heroes on the scale these days, but I think its falling in mindless popcorn.  I still love to read, but I manage to only really do it on the commuter train or just before bed as long as Sarah is okay with me leaving the light on.  The video games, those have really suffered, but I’m trying to make up for it now.

Bonus fact so that I cannot be accused of ignoring my wife: I was asking Sarah for some ideas for this post, and she gave me “I like to uphold family traditions.“  I don’t really see that in my indentity when I think about myself, but looking at past actions and what I like to do with the kids, I can agree with this.  From eating under the tree at Field’s Macy’s at Christmas time to vacations in the same spots I went as a kid, this certainly appears to be true.

Okay, so next up I have to call out seven people:

To quote Evo who tagged me: “I subscribe to all of your blogs, so I’ll know if you didn’t do it…”

Oh yeah, the rules part:  Do not talk about meme club…er.. wait

  1. Link your original tagger(s) and list these rules in your post.
  2. Share seven facts about yourself in the post.
  3. Tag seven people at the end of your post by leaving their names and the links to their blogs.
  4. Let them know they’ve been tagged.

Small fix for WordPress XML-RPC

I had the idea that I might photo blog more if there was an easy way to get photos off my iPhone and into a blog post.  The easiest way would be to e-mail the photo someplace for WordPress to get it.  Unfortunately, most of the e-mail to blog post plugins (and the built-in stuff) just sucks for my need.

I decided to look at the XML-RPC API to see if I could get it done that way, and then write a script to be called out of procmail to create the mail.  There is a function there that will do what I want, wp.uploadFile aka metaWeblog.newMediaObject.  The specification for that call says that the file being uploaded must be Base64 encoded.  No problem, a few line of ruby later and I have everything ready to test an upload.  The file goes up, but its unviewable in a browser.  A quick check of the file on the server and its revealed to be a text file filled with Baes64 looking data.  Somewhere along the line it wasn’t being decoded.

After about an hour of screwing around, I determined it wasn’t anything obvious in my code, so I thought I’d look at the code for WordPress 2.5.1 to see if I missed anything obvious.  In reading their code, I found that the WordPress folks forgot something obvious, their code never Base64 decodes it before it writes it to a file.  A quick one-line change later, and *boom* I’m off.

Here’s the patch in case its useful to anyone else. I’ll have the script up when I’m done with it.

(Also, in a small bit of embarrassment, I must admit fixing this took me 10 minutes longer than it should because I forgot ; is end of statement in PHP.)

Index: xmlrpc.php
===================================================================
--- xmlrpc.php  (revision 7840)
+++ xmlrpc.php  (working copy)
@@ -1880,6 +1880,10 @@
                        $name = "wpid{$old_file->ID}-{$filename}";
                }
 
+                # The specification says that this is base64 encoded,
+                # we should really decode it.
+                $bits = base64_decode($bits);
+
                $upload = wp_upload_bits($name, $type, $bits);
                if ( ! empty($upload['error']) ) {
                        $errorString = sprintf(__('Could not write file %1$s (%2$s)'), $name, $upload['error']);

Great syntax highlighting plugin for WordPress

At times, I think I spend more time writing about using wordpress than actually using it sometimes. I’ll need to fix that. Today, thanks to WordPress’s dashboard, I came across the WP-Codebox plugin. THanks to GeSHI, it can color up a lot of languages and fixes some problems I’ve had with other plugins. Honestly, I’ve never been satisfied with any of them. I think this could change that.

Just to show it off, I present to you some random ruby I wrote the other day when I was working on something. I’ll leave it to you to guess what I’m doing and why with this code. (And I also think I could do it better than using a while loop, but I was able to bang it out quickly for what I needed.)

#!/usr/bin/env ruby
require 'fileutils'

srand(Time.now.to_i)
offset = 214

files = Dir['*']

count = 1
while !files.empty?
  file = files.delete_at(rand(files.size))
  extention = File.extname(file).downcase
  name = sprintf('%d%s', count + offset, extention)
  puts "#{file} -> #{name}"
  FileUtils.move(file, name)
  count += 1
end