jeremiah blog

  • About

Geotagging SmugMug Images

Posted by jl2 on May 28, 2012
Posted in: coding, computers, news.

I’ve created a new website for geotagging photos on SmugMug using GPX files.

I named it geosmug.

Right now the interface and feature set are pretty minimal but it gets the job done.

First, the user uploads a GPX file and selects one of their SmugMug galleries. Then they’re shown the photos on a map and a few controls for matching up the GPX and photo timestamps, in case they don’t match. Finally, they submit the timestamp adjustments and the software adds the geotag data to SmugMug.

It also allows removing geotag data from photo galleries.

I plan on adding a few more features and polishing the interface a bit, but the current version is already usable, so I decided to write a blog post about it.

In the future I’d like to add support for Flickr, but for the next few weeks I’ll be focusing on improving the SmugMug version.

It requires a one time $5 signup fee, but it’s possible to try it out for free. Of course no changes can be saved until it’s been paid for…

Conway’s Game of Life in Javascript and WebGL

Posted by jl2 on April 15, 2012
Posted in: Uncategorized.

The other day I started looking into WebGL. I’m not sure there are many good uses for 3D graphics inside a web browser, but it’s interesting to look into, and easier to share than regular OpenGL programs, so there’s some value to it, at least.

One idea I have is to tie it in with some stuff I’m doing at work to view tessellated CAD models in a web browser. There’s not a big audience for it, but it’d be neat for sites like GrabCAD and some of the 3D printing sites that are popping up lately.

Before jumping into large stuff like that, I’ve been looking at some smaller projects.

The first thing I created is a version of Conway’s Game of Life. It’s not very fancy, and it’s only 2D right now, but it was a good exercise in basic WebGL. At some point I may make a 3D version, though I’m not sure Javascript and WebGL will be fast enough to handle it.

All of the source code, along with some other random WebGL code, is available on GitHub.

WebGL isn’t supported very well yet, so this only works in Opera 12 alpha, newer versions of Chrome, and maybe some versions of Firefox. Here’s what it looks like:


Your browser does not support WebGL!

Static HTML Embedded Gists

Posted by jl2 on December 22, 2011
Posted in: coding, computers. Tagged: coding, gist, git, github, PyQt, python, Qt.

I use GitHub a lot, and one of my favorite features are "Gists". They’re basically just a fancy way to share code snippets, but backed up by a mini Git repo. They also allow you to embed syntax highlighted source code into other web pages.

One thing I didn’t really like is that embedding a Gist into a page requires a lot of Javascript and HTTPS requests to the GitHub servers. It’s not a huge deal, but it slows things down a little bit.

So, I created the script below. It takes a Gist ID as a command line parameter, downloads it and runs the Javascript code through Qt’s Javascript interpreter. It intercepts the document.write calls to get the raw HTML. The results can be pasted into a static HTML page, or in this case a blog entry as raw HTML.

To reduce HTTP traffic and speed things up even more, the script strips out the link to GitHub’s gist stylesheet. To compensate, I added the content of that stylesheet to the stylesheet for the WordPress theme I’m using. I also had to tweak the rule for ".gist .gist-file .gist-data pre" a little bit, to set the line-height property back to 1.

In all honesty, executing the Javascript here is overkill. A few calls to string.replace() would be as effective and probably faster. But that wouldn’t give me an excuse to play with using Qt’s Javascript engine from Python :-)

#!/usr/bin/env python3

import urllib.request
import sys

from PyQt4 import QtGui
from PyQt4 import QtCore

from PyQt4.QtScript import QScriptEngine, QScriptValue

def doc_write(context, eng):
    if context.argumentCount() != 0:
        na = context.argumentCount()
        args = list()
        for i in range(na):
            args.append( str(context.argument(i).toVariant()))
        temp = ' '.join(args)
        # if not 'embed.css' in temp: broke when running the script on itself!
        if not temp.startswith('<link rel="stylesheet"'):
            temp = temp.replace("\n", '')
            print(temp)
    return QScriptValue('')

def main(args):
    gist_id = None
    if len(sys.argv) > 1:
        gist_id = args[0]
    else:
        print("No Gist ID given!")
        exit(0)

    url = "https://gist.github.com/{gist_id}.js".format(gist_id=gist_id)
    app = QtCore.QCoreApplication(args)
    qse = QScriptEngine()
    dw = qse.newFunction(doc_write)
    qse.globalObject().setProperty('doc_write', dw)
    
    fh = urllib.request.urlopen(url)
    gist_script = fh.read().decode('utf-8')
    gist_script = gist_script.replace('doc_write', 'doc_write')
    res = qse.evaluate(gist_script)

if __name__ == "__main__":
    main(sys.argv[1:])

view raw gisthtml.py This Gist brought to you by GitHub.

Handy shell script

Posted by jl2 on August 28, 2011
Posted in: coding, computers.

A while back I needed to free up some hard drive space. To free up the most space as quickly as possible, I wanted to focus on the larger directories first.

Of course there are a lot of utilities, like KDirStat, to do that sort of thing, but I didn’t need anything that fancy.

The solution I came up with is the following Shell/Perl one liner:

#!/usr/bin/zsh

ls -Q -d . | xargs du -b -- | \
sort -n |\
perl -e 'while (<>) { @p = split; $sz = shift @p;\
    printf("%3.2f MB \t@p\n",$sz/(1024*1024)); }'
view raw dud This Gist brought to you by GitHub.

I had to break it up into a few lines so it’d fit in the narrow column here, but it works just as well with the line breaks removed.

Here’s a sample run:

[jl2:debianlap ~/src/cgeom] dud
0.00 MB ./.git/branches
0.00 MB ./.git/objects/info
0.00 MB ./.git/refs/tags
0.00 MB ./.git/refs/remotes/origin
0.00 MB ./.git/refs/heads
0.00 MB ./.git/refs/remotes
0.00 MB ./.git/refs
0.00 MB ./.git/logs/refs/heads
0.00 MB ./.git/logs/refs
0.00 MB ./.git/info
0.00 MB ./.git/logs
0.00 MB ./datastructs/tests/__pycache__
0.01 MB ./svgimg
0.01 MB ./geom
0.01 MB ./ch2/tests
0.01 MB ./datastructs/__pycache__
0.01 MB ./datastructs/tests
0.01 MB ./ch1/tests
0.01 MB ./ch2
0.02 MB ./.git/hooks
0.02 MB ./.git/objects/pack
0.02 MB ./.git/objects
0.03 MB ./datastructs
0.04 MB ./.git
0.06 MB ./ch1
0.16 MB ./

I’ve found it to be 10x more useful than the regular “du” command, so I thought I’d put it up here in case anybody else wants to use it.

I could probably make it shorter using just Perl, but it doesn’t seem worth the effort, so I haven’t bothered.

Heightmap Animation

Posted by jl2 on August 27, 2011
Posted in: coding, computers. Tagged: 3delight, c, coding, gdal, graphics.

A while back I wrote this small program to create animated heightmaps using USGS elevation data, 3Delight, and GDAL.

Here’s a sample of the output:

Height Map Animation from jlarocco on Vimeo.

I have to admit it isn’t very useful, but I learned quite a bit about using libgdal, 3Delight’s C interface, and how to get data from the USGS website. And some of the animations look cool, so that’s also nice.

The source code has a few parameters to tweak the image quality at the cost of memory usage. The animation above was rendered on my laptop, so I had to decrease the quality a bit.

Using Pinboard.in with Opera

Posted by jl2 on June 28, 2011
Posted in: computers. Tagged: computers, internet, pinboard, web.

A while back I signed up with Pinboard.in and stopped using my delicious.com account. Pinboard is pretty awesome, and there are plugins/extensions for Chrome, Firefox and Safari, but not much for Opera except for the generic “bookmarklets“. Fortunately, Opera is customizable enough that no extra plugins are really necessary.

Keyboard Shortcuts

The trickiest part was adding keyboard shortcuts for bookmarking. The shortcut editor in Opera isn’t very intuitive, so this was more difficult than I expected. My goal was to have F9 add the current page to “Read Later”, F10 to bring up the “Bookmark with Tags” page, and for F11 to bring up my Pinboard bookmarks. Eventually I was able to get it working. I think the important things are:

  • Add the shortcuts under the Application section
  • Make sure single key shortcuts are turned on
  • Make sure the correct shortcuts are selected in the “Keyboard setup” list. Sometimes the change doesn’t seem to take effect…
  • Make sure F9, F10, and F11 aren’t mapped to anything else anywhere.

The following can be copy/pasted into the keyboard .ini settings file. Or, copy paste everything after the ‘=’ into the keyboard shortcut editor.

; Read Later
F9=Go to page,"javascript:{q=location.href;p=document.title;void(t=open('https://pinboard.in/add?later=yes&noui=yes&jump=close&url='+encodeURIComponent(q)+'&title='+encodeURIComponent(p),'Pinboard', 'toolbar=no,width=100,height=100'));t.blur();}"

; With tags
F10=Go to page,"javascript:{q=location.href;if(document.getSelection){d=document.getSelection();}else{d='';};p=document.title;void(open('https://pinboard.in/add?showtags=yes&url='+encodeURIComponent(q)+'&description='+encodeURIComponent(d)+'&title='+encodeURIComponent(p),'Pinboard', 'toolbar=no,width=700,height=600'));}"

; Go to Pinboard.in
F11=Go to page,"https://pinboard.in/u:jlarocco/"

Searches

Next I added two custom searches for easy access to my bookmarks.

The first one, with shortcut “pbt” uses the URL “https://pinboard.in/u:jlarocco/t:%s”, goes to my Pinboard page and displays all bookmarks with a certain tag:
pbt Search

The second one, with shortcut “pb” uses the URL “https://pinboard.in/search/?query=%s&mine=Search+Mine”, will search all of my Pinboard bookmarks:
pb_screenshot

With the above configuration it’s almost easier to use Pinboard than it is to use Opera’s built-in bookmarking functionality.

New Project

Posted by jl2 on May 28, 2011
Posted in: Biking, coding. Tagged: biking, business, coding, internet, website.

The other night while riding my bike after work, I realized that I ride one of two routes almost every day. I had never really thought about it before, but for some reason it really bugged me. I have “alternate” routes for when the trails are too muddy, or if it’s really snowing and cold, but usually it’s the same ride all the time.

I kept thinking about it, and before long I had a solution: I could create a database of all the rides I can access from work and setup a cron job to send a randomly selected ride to me every day. It was a long ride, though, and the more I thought about it, the more features I came up with. Before too long I had a whole list of features, and it started to seem like a really cool idea.

So my new project is going to be a website, After Work Rides.

I spent most of today setting everything up so that I can get started. I decided to make the site using Python3 and the Bottle web framework. Dreamhost provides MySQL databases, so that decision was made for me. Unfortunately, I had to install Python 3.2, Bottle, and the MySQL DB connector myself, because Dreamhost only provides old versions. Not difficult, but it had to be done.

After the hosting was setup I signed up for a Google Maps API key, created a new repo on Github and setup a simple landing page.

Finally I can get to work on the interesting part of actually developing the site…

New Single Speed

Posted by jl2 on May 14, 2011
Posted in: Biking, Outside. Tagged: biking, single speed.

Single Speed 1

I just got a great deal on a single speed mountain bike at the Trek store in Louisville. They’re giving $100 off every bike in the store for the entire month of May.

Despite the great deal, my decision to get a single speed was somewhat spur of the moment. I spent a good portion of the morning cleaning the chain and derailleurs on my regular bike. Like usual, I spent the entire time making a mess and hating it. This time it bothered me so much I decided to do something about it. Single speeds are simpler mechanically, and are supposed to require less maintenance.

I plan on keeping my regular mountain bike for longer trips and for serious mountain riding. But for my daily commute and after work rides, I’ll probably stick with the single speed. Rumor has it that single speeds make your legs stronger, so that may be a nice bonus.

Single Speed 2

Mountain Biking Season

Posted by jl2 on May 9, 2011
Posted in: Biking, Outside. Tagged: biking.

After reaching my goal of skiing 50 days during the 2010-2011 season, I’ve been having a hard time motivating myself to go anymore. I still think about going, and I keep telling myself I’ll go again, but I really don’t know when. The super nice weather isn’t helping much – 75 degree bluebird days just aren’t skiing weather. I’ve been dying to go camping or on a backpacking trip, but unfortunately there’s still too much snow in the mountains.

That means it’s the perfect time to spend the weekends mountain biking. The last few weekends I’ve been doing some variation of this loop.

It’s a really great loop because it can be as long as I want it to be, and it covers all kinds of terrain, from the road to single track. Maybe best of all, I don’t have to drive to get to it. Sunday’s ride was the longest variation I’ve done, and is shown in the GPS track above; a 51 mile loop with ~3000 feet of elevation gain that took about 4.5 hours. the only thing that would make the ride better is if there were more trails and fewer roads. I’ve been looking for ways to do that, but haven’t had much luck.

Also over this last weekend, I rode out-and-back on Westminster’s Big Dry Creek trail, from my apartment to I-25, and back. It’s only ~18 miles, so I added a loop around Standley lake. It’s not a very exciting ride, but I get so bored riding on the street to and from work, it’s a nice change to ride any kind of trail.

The next few weekends I may actually drive out to the foothills and do some biking there. Usually, I don’t like driving to go for a bike ride, but I’m really anxious to get out on singletrack this spring. I think next weekend I’ll head over to the Walker Ranch Loop. A friend and I hiked around it a couple years ago, and it looks like a great place to ride. I might even go crazy and ride all the way to the trailhead, do the loop, and ride home, but that’d be a pretty long day. Guess I’ll see how I feel next weekend..

Skiing East Wall

Posted by jl2 on March 12, 2011
Posted in: Outside, Skiing. Tagged: abasin, arapahoe basin, east wall, skiing.

Today I skinned up A-Basin from the parking lot to the upper section of East Wall, then skied down North Chute, back to the parking lot. To get a feel for backcountry skiing, I was wore a full pack, including my avalanche beacon, probe and shovel.

It was my first time skiing with a pack on, and in retrospect, it was probably a mistake to ski a 45° slope right off the bat. It went okay, though, and once I got to more mellow terrain everything went great. Tomorrow I’ll try without the pack.

This video isn’t the greatest, but it shows the view well enough:

And the GPS track of the skin up and ski down…

Posts navigation

← Older Entries
  • My Other Stuff

    • 14ers.com
    • Github
    • Last.fm
    • Pinboard
    • Resume (xhtml)
    • SmugMug
    • Twitter
    • Vimeo
  • Friends

    • Gimlin
    • Robert Tadlock
Proudly powered by WordPress Theme: Parament by Automattic.