Displaying articles with tag

Photoslice in Bluecloth and Mephisto

Posted by hank, Sat Jan 05 16:49:00 UTC 2008

So, I found this today, and it is awesome. I wanted it in Bluecloth so I could use it in Mephisto. Here’s how.

First, I needed to make it so I could still do normal images, but turn on coolness if I want. Here’s the goal I came up with for the grammar:


[![](thumburl.jpg)](imageurl.jpg "Scrolly Text at top" "photoslice")

Here’s the first test, with a single image:

And now a set with a namespace:

I did it by simply modifying the regex and image url parsing function in BlueCloth like so:

  InlineLinkRegex = %r{
    \(            # Literal paren
      [ ]*        # Zero or more spaces
      <?(.+?)>?     # URI = $1
      [ ]*        # Zero or more spaces

      (?:         # title
        ([\"\'])    # Opening quote char = $2
        (.*?)     # Title = $3
        \2        # Matching quote char
      )?          # Title is optional
      [ ]*        # Zero or more spaces
      (?:         # rel
        ([\"\'])    # Opening quote char = $2
        (.*?)     # rel = $5
        \4        # Matching quote char
      )?          # rel is optional
    \)
    }x

    # and later...

        # ...or for an inline style second part
        elsif @scanner.scan( InlineLinkRegex )
          url = @scanner[1]
          title = @scanner[3]
          rel = @scanner[5]
          @log.debug "  Found an inline link to %p" % url

          text += %{<a href="%s"} % escape_md( url )
          if title
            title.gsub!( /"/, "&quot;" )
            text += %{ title="%s"} % escape_md( title )
          end
          if rel
            rel.gsub!( /"/, "&quot;" )
            text += %{ rel="%s"} % escape_md( rel )
          end

I also added the following to my Mephisto theme layout, in the head section:


   <!-- Photoslice -->
   <link rel="stylesheet" type="text/css" href="/javascripts/photoslice/style.css" />
   {{ "photoslice/functions.js" | javascript }} 

Once again, Ruby is awesome. And so is Markdown.

Tags:

Finding bad JPEGs with Xorg hacks in Ubuntu

Posted by hank, Sat Nov 24 19:46:00 UTC 2007

So, I have all these JPEGs, and I want to know which ones are corrupt (specifically, ones that end prematurely). qiv will spit out the following to STDERR when it finds one:


Premature end of JPEG file

So, this is nice, except it’s entirely unscriptable. The solution I found was using the following script to the display the images in sequence:


perl -e 'for(glob("*.png *.jpg")){$output = `qiv "$_" 2>&1;`; if($output =~ /Premature/){print $_, "\n";}}'

All this does is mix STDERR with STDOUT for a qiv of the file, and check the output for the word “Premature”. If it finds the word, it prints the filename. Simple.

The only problem is that qiv doesnt have a way to just check whether a JPEG file is corrupt (and if there is a command line utility that does, please let me know). To make it go thru the list, I wrote this little gem:


while(true); do xte "key q"; done

All this does is send the q key to the Xserver infinitely. All I have to do is put focus on the first qiv window to make it and all subsequent qiv windows receive q’s. So, just run it, and click on the window. Then there are lots of flashes, and eventually that perl script will print out the names of the bad files. It’s totally ghetto, but it’s the best I’ve got right now. The point of this post is to hopefully find new ways to do this more programmatically.

Tags:

Does Alicia Silverstone love meat?

Posted by hank, Thu Sep 20 21:14:00 UTC 2007

I saw this today, and thought it was hilarious. Basically, this is the main point of the whole thing:

So I decided to have some fun.

Continue Reading Tags:

Setting EXIF dates with a loop

Posted by hank, Mon Sep 17 20:11:00 UTC 2007

Magic EXIF recursive tagging!

Have you ever had your files all nicely nested in directories, but needed to change their EXIF dates? Here’s what I used today to do it:


# Structure like this: 1997/08/Picture.Whatever Maybe Some Spaces.jpg

# Delete the EXIF tags (DONT DO THIS UNLESS YOU KNOW WHAT YOU'RE DOING!)
find . -mindepth 3 -exec jhead -de "{}" \;

# Make Fresh EXIF tags
find . -mindepth 3 -exec jhead -mkexif "{}" \;

# Set the dates according to the Year and Month information in the filenames
find . -mindepth 3 | perl -ne '@a = split(/\//, $_); chomp($_); print `jhead -da$a[1]:$a[2]:01-2007:09:17 "$_"`, "\n"'

This worked wonderfully.

Tags: