battis.net and I'm all out of bubble gum…

YouTube has changed their embed codes (several years ago) to IFRAMEs, replacing the old object embed codes. Turns out that on older web-based WYSIWYG-editors, such as Blackboard 8, the IFRAME embed codes get munged up, often with deleterious effects. In Blackboard, for example, you might lose the ability to see, edit or use a content area in which an IFRAME has been embedded. This. Is. Bad.

YouTube lets you switch to their old embed code for individual videos, but no so to embed a playlist. I wanted to embed a playlist, so I took a look at the object tag specs and the IFRAME embed code and came up with a simple script that generates an old-style object embed code for a YouTube playlist IFRAME embed code, thus:

Paste a YouTube playlist embed code below.

November 30th, 2012

Posted In: How To

Tags: , , , , , , , ,

For the last few years (my JSON feed tells me: since 2008), I have been tagging and annotating articles of interest as they passed before my eyes in Google Reader. This served a two-fold purpose:

  1. I could find them again later, easily, because they were tagged and annotated.
  2. I could share an RSS feed with those annotations to particular interest groups that I worked with (e.g. anything tagged “for robotics” would show up on my advanced computer science class’ portal page, or anything tagged “for academic computing” would show up on my school home page).

This was a great way to share (and manage) resources. Granted, much of what passed before my eyes in Google Reader was trivial and not of lasting value, but this filtering allowed me to hang on to at least a few gems for future reference.

And then Google Reader got the Google+ treatment and sharing items broke. But you could download a JSON dump of all the items that you had ever shared. It wasn’t entirely clear what you could do with this JSON dump, but… there it was. And then: I realized that all of my other information is stashed on my web server (and that I have become increasingly distrustful of relying on cloud services to maintain my data and workflows — e.g. my weekly backup of all my Google Docs… just in case).

Wouldn’t it be handy to import that JSON feed into a new blog on my server? So I wrote a PHP script that converts (at least my) Google Reader JSON dump into an XML file that WordPress can import as a list of posts. With the tags and annotations converted over. In fact, with all of the data in the JSON dump embedded in the XML file (although WordPress doesn’t read all of it).

This comes with a few caveats:

  • For items that came from blogs with a full feed, the result is a republication of the original post — which feels ethically dubious to me. (I have made my new blog of Google Reader shared items private, so that I have the data but I’m not sharing it with the world).
  • I’ve made guesses as to how to treat some of Google’s data. Reasoned, educated guesses, but guesses nonetheless. For example, I’m not super-clear on which dates in the file correspond with what events — does a publication date refer to when the item was shared or the original post was posted?
  • I’ve added in some arbitrary (and therefore, ideally, eventually, configurable) WordPress tags to make the import go more smoothly. Where I have done that, I mark it in the script as a TODO item. (And, in truth, I didn’t really test to see if all of these items were necessary.)
  • The original authors of the posts are transfered to the XML file, which means that when the actual import into WordPress is done, you will have the option to either laboriously create a new user for each distinct author or simply revert authorship to the currently logged-in WordPress user. It doesn’t seem like WordPress has a format for exporting or importing users (or, at least, my cursory search didn’t find it). Clearly an ancillary SQL query could be generated that pre-populated the WordPress database with the users that the XML file refers to. But I haven’t bothered to do that.
  • You’ll need your own PHP-compatible webserver to run the script, since I have been quick and dirty and simply imported the JSON file from and exported the XML file to the script’s local directory. And I have no interest in setting up my world-facing webserver to take the traffic hit of processing other people’s multi-megabyte JSON dumps.
With that said, here is the script, as it stands this morning.

November 27th, 2011

Posted In: How To, Social Bookmarking, Social Media, Useful Tools

Tags: , , , , , , ,

My inner librarian is strong. Perhaps too strong. I have a large collection of photos from Flickr that I use for my desktop wallpaper. A couple times each week, someone comments on my desktop and wonders where I got the photo. So, I was pondering the problem of reverse engineering the garbage-strings of numbers that Flickr auto-generates for a filename to get a link back to the original photo. Some quick Googling led me to this tidbit. And some a quick PHP scripting resulted in this:

Flickr Filename to URL Converter

Filename (file extension optional):

Feel free to paste in your own Flickr filenames to find the URL of the original image. The script will send you directly to the original image page.

February 14th, 2010

Posted In: How To

Tags: , , ,

So, I’ve spent the last few days wrestling with a curriculum unit that an outside consultant built. In PowerPoint. On Windows. And which we have been trying to set up in such a way that we can share the interactive document with students. Who are using Macs. And, perhaps, without asking each student to download a ~200MB file to use it.

I have learned and grown much in the process. And have discovered that Microsoft PowerPoint 2008 does an execrable job of exporting PowerPoints as web pages (it does an execrable job of doing a lot of other things too, but we can talk about that at another time). Here are the key fixes that I made to the exported web page and supporting files so that the presentation would fundamentally work (all of this was done using regular expressions in TextMate):

  1. I stripped out all of the fancy Javascript calls that PowerPoint inserted as links to navigate from one slide to another. It turns out that a simple HREF to the actual page’s HTML file works (and the JavaScript Does Not.)
    Find:

    (href=")[^"]*(slide\d{4,4}.htm)[^"]*(")

    Replace with:

    $1$2$3
  2. The export to web page takes all of the already URL-encoded links in the PowerPoint and reencodes them, rendering them useless. I stripped off the second encoding.
    Find:

    (%)25([a-fA-F0-9]{2,2})

    Replace with:

    $1$2
  3. Finally, because the links were built in Windows and then URL-encoded, all of the Windows-style paths needed to be turned into POSIX paths for use on the web.
    Find:

    %5[cC]

    Replace with:

    /

At this point, in an average PowerPoint, most of the damage has been fixed and things more or less work. However, the curriculum unit that we were working with also linked to external Word documents (hence some of the Windows-style path issues above). This meant I had a few more fixes along the way that are worthy of note:

  1. I replaced the links to Word documents with links to the corresponding PDF files (and script I used generated PDF files with .doc.pdf extensions and I didn’t bother to fix that).
    Find:

    (href="[^"]*docx?)(")

    Replace with:

    $1.pdf$2
  2. These links to external documents open in the same frame as the slideshow. Which defeats the purpose of the slideshow being a navigational tool. So I redirected all of the new PDF links to a new window in the browser. As the hyperlinks are broken across two lines in the HTML source code, this took two steps.
    1. Find (changing {{name of Links & Sources folder}} to the, well, actual name of the Links & Sources folder):
      (href="((http://)|({{name of Links & Sources folder}}))[^"]*")\n

      Replace with:

      $1
    2. Find (modifying as noted above):
      (href="((http://)|({{name of Links & Sources folder}}))[^"]*"\starget=")_top(")

      Replace with:

      $1_blank$5

September 24th, 2009

Posted In: Educational Technology, How To

Tags: , , , , , , , , , , ,

css.php