General Tech
Gallery::Remote::API
by Jon on Jun.15, 2010, under Babble, General Tech, teh internets
Awesome… all my futzing around with Gallery has led me to release my first perl CPAN module — Gallery::Remote::API, a perl module for interacting with a Gallery installation via Gallery’s remote protocol.
Funny thing was, halfway through writing it I realized the remote protocol itself didn’t let me do what I set out to do in the first place … it actually doesn’t let you do much besides fetch info and add images. Oh well, maybe someone will find it useful. It was a good exercise for me just to get a handle on packaging a module for distribution.
wordpress, gallery, and canonical urls
by Jon on Jun.12, 2010, under Babble, General Tech, teh internets
I just know you wanna know what sort of fun I’ve been having this morning.
OK, so I’m playing around with an installation of WordPress featuring an embedded installation of Gallery2 via the excellent WPG2 plugin. And I’ve got all my fancy url rewriting set up on both platforms.
So what happens is, when you go to “site.com/galleries”, you’re going to a wordpress page, at which point wpg2 does some fancy footwork to embed the appropriate gallery page, so when you go to “site.com/galleries/myalbum/” it shows that album’s page, and “site.com/galleries/myalbum/myphoto.html” shows that photo’s page, etc., all wrapped up inside your usual WordPress header, sidebar, and footer. So far so good.
Here’s the thing: Gallery’s url-permalink stuff correctly writes out the album links as “site.com/galleries/myalbum/”, but I kept getting 301 redirects to “site.com/galleries/myalbum” (notice the trailing slash difference). Now that’s not a completely insufferable thing — it does get you the correct content. But there are both performance and SEO considerations. On the one hand, you don’t want to 301 if you don’t have to (waste of bandwidth and slows down the user experience); on the other hand, you do only want one version, whichever it is, to be the “accepted” version, while the other 301s back to the first, otherwise you split your ranking juice between the two urls, and may get penalized for duplicate content.
So the easy solution would probably have been to hack Gallery and remove the slash wherever it generates links (and where it generates the rel=”canonical” link in the header [which Gallery itself doesn't actually do, I had to put that in my custom theme myself]). Except that IMHO, the slash should be there in this case — in my mind, an album is a directory, as evidenced by the fact that “files” (photo pages) exist beneath it.
So I set about trying to figure out who was redirecting my slash back to no-slash by poking around in all my redirect rules. Now that’s not an easy task, given that wordpress and gallery both write their own .htaccess files, wpg2 writes a modified version of gallery’s mod_rewrite rules into the wordpress .htaccess, and on top of that, apparently WordPress ALSO has a whole set of “virtual” rewrite rules that don’t show up in the .htaccess file. Compound this by the fact that Dreamhost doesn’t seem to let me turn on mod_rewrite’s RewriteLog, and by the fact that the galllery links have to go through some valid rewrites to get them first in a form that wpg2 can understand, and then into a form that gallery itself can understand — well I drove myself nuts trying to figure out where it was happening.
Finally out of sheer frustration I grepped for “301″ in the wordpress source code — and sure enough, I found a sneaky little wordpress function called redirect_canonical was the culprit. Apparently anytime it gets a “site.com/url/” (at least one that doesn’t actually point to a real live directory — I think), it removes that slash and 301s.
Now, normally, that’s probably the right thing to do. If someone goes to “site.com/myblogpost/”, it probably should redirect to “site.com/myblogpost”, and consider the slashless version canonical — since a single blog post/page/whatever is really more like a file than a directory. But it’s not appropriate in this embedded gallery situation. Luckily, wordpress does provide a whole system of filters and hooks with which you can fix this.
So, if you’re in a similar situation, you can add something like the following to your theme’s “functions.php” file, and that should do the trick:
//don't let wordpress "canonicalize" gallery virtual directories
function g2_reverse_canonical($rd_url,$rq_url) {
global $user_url;
$pattern1 = "~^$user_url\/galleries\/([^.]+\/)+(\?[^?]*)?$~";
$pattern2 = "~^($user_url\/galleries\/([^.]+\/)*([^.]+))(\?[^?]*)?$~";
if (!empty($rd_url) &&
preg_match($pattern1,$rq_url)
) {
#don't do it!
return false;
}
elseif (empty($rd_url) &&
preg_match($pattern2,$rq_url)
) {
#reverse it!
return preg_replace("~(\?[^?]*)?$~","\/${1}",$rq_url);
}
#otherwise, let wp do what it wants
return $rd_url;
}
add_filter('redirect_canonical','g2_reverse_canonical',10,2);
Of course you’ll want to replace “galleries” in those regex patterns with whatever path you chose for your gallery permalinks. It seems to work for me — at least, I haven’t found any bugs so far (if anyone who knows more about this stuff than I sees an issue, I’m all ears). Notice that in addition to stopping wordpress from removing the slash, I also do the reverse and add the slash when it isn’t present. It might be more efficient to move that part to an .htaccess mod_rewrite rule, but I wanted both actions in the same place for the sake of my sanity.
Further, note that it does NOT apply if the final token (prior to any query string) contains a “.” — this lets wordpress correctly do it’s thing and canonicalize the “site.com/myalbum/myphoto.html” pages without the slash. Of course the downside is that you can’t have a “.” in your album names (but since gallery album names — as far as the url is concerned — are the actual directory names where the data is stored, hopefully it’s not a problem. Yeah, you can create directory names that have a “.” in them, but hopefully you’re sane enough not to do so :)
Finally, I also let wordpress take it slashless when just going to “site.com/galleries”. Personally, I think that too should be treated like a directory, but since it’s technically a wordpress “page”, and since in this case Gallery is also generating links without the slash, I’m just going to let that one be.
And I still hate PHP.
I can’t be merry, ‘cuz I’m Hebrew, on Christ-mas
by Jon on Dec.26, 2009, under Arts & Entertainment, Babble, Buddhism / Taoism, Essence, Food & Beverage, General Philosophy, General Tech, Life, Memes, Music, My Trip to Mecca, Politics, South Nashville, TV & Movies, Theater / Opera
so here we go;
sorry I haven’t written much here lately. I have no greater excuse than simply not having been in the right frame of mind.
Well. Don’t know when I’ll be back, but I’m here. And it’s Saturday night, after Christmas. It’s been a decent one. Thursday with the dad, brother, and brother’s family, at Granny’s house, which Dad has now inherited. I think I hit a home run with the Fart Machine I gave my nephew. And another, with a most politically incorrect documentary in which the esteemed civil libertarian boundary-pusher Larry C. Flynt chronicles the accomplishments and exploits of an Alaskan pin-up queen gone rogue. We’ll leave the rest to your imagination or google-fu.
Saturday, pizza, party, and presents with the sister and her husband, which rocked. Never doubt the badassedness of four fresh diced jalapeños and a smattering of mushrooms taking a Digiorno to the next level, especially when you wash it down with a steady flow of a brew-kit bitter and a back supply of the same brew-kit’s dark ale. We backed the food with the Mr. Hankey’s Chrismas Classics dvd, and the beer with Weird Al’s videos dvd, which culminated in the main event of Christmas at Ground Zero. Then to the living room for presents, with Koyaanisqatsi muted, just for the visual, and the TSO playing on on the PC/stereo. Good Times. As far as the gift, my & my sister and I have this long running calendar gag, and I won’t bore you with the details but I think I rocked it this year.
So then today I guess is xmas for me. Cleaned up from the party, then spent the day in lazy, beer-sipping play and exploration. I finally opened up the School of Rock dvd that’s been sitting on my coffee table for months. I can’t tell you how much I love the hell out of that movie. It’s stupid, it’s sappy, but goddamn it it rocks and I love it. Of course I’ve seen it too many hundred thousand times on TBS, so I didn’t need to watch it, but watched it with the commentary from Jack Black and the director, then went back and just watched the “one hell of a rock show” chapter. Man, for a stupid movie song, they nailed it. Just enough Yes, Kiss, Bowie, and Floyd all mixed up and dished out over a plate of AC/DC — fuck yeah. And yes, I fucking cry every time when Turkey Sub struts up to the mike and belts out loud and clear how happy she is to be who she is in a glorious declaration. And though I’ve got my issues with the keyboard kid — I would have liked to have seen a little less Rick Wakeman, a little more Ray Manerik with a helping of Jon Lord (that just would have been more rock and roll to me) — I understand better after the commentary that yeah, Wakeman was probably the perfect archetype given the actor/pianist’s true to life classical upbringing and utter unfamiliarity with rock. And even still I did always like the somewhat-Wakemanesque, but almost more Come Sail Away-era-Denis DeYoung sounding portamento-drenched monotimbral solo he does there. My kinda shit, actually.
Had an awesome dinner (yellow saffron rice, with red onions, fresh jalapeños, and mushrooms, well seasoned and sautéed with a Morningstar Veggie Italian Sausage, if you give a damn), then put on Naqoyqatsi, another dvd I’ve owned for a while but been waiting for the right time to watch. Except that I still haven’t watched it, I’ve just been listening as I typed this post. Well, it *is* Glass, it needs at least one listen by itself without the visual.
And it just ended. Guess I should grab another beer and watch it for real this time.
let’s all go to the lobby
by Jon on Jul.12, 2009, under Arts & Entertainment, Babble, General Tech, TV & Movies, teh internets
Man, Netflix is getting really specific. The first “category” on my homepage is now “Dark Tortured-Genius Dramas”.
On a similar track, I’ve always been annoyed that they only give us 5 stars to rate with, no half stars, etc, and usually when I go to rate one I’m thinking, “well this one’s really a 3.5″, etc… Well it’s almost getting creepy how often their “Average of raters like you” — which does do half-stars — matches how I would have rated had they let me.
And while I’m talking Netflix — I haven’t decided if I like their connection widget I’ve been playing with that posts my ratings to facebook. Or rather I do like it for the ones I want to post, especially now that they’ve added the ability to comment, but I don’t like that it posts everything I rate. And not just the ones I’ve just rented, it posts *everything* you rate. So when they give you a page of recommendations and you go through rating all the ones you’ve already seen it posts those too. I do watch a lot of movies, but not as many as it makes it seem. Seems like it would be simple to add a “don’t post this one” to the little dialog that pops up asking for your comment.
sometimes things suck in awesome ways
by Jon on Jan.03, 2009, under Arts & Entertainment, Babble, Food & Beverage, General Tech, Life, Theater / Opera, teh internets
After stumbling to the computer this morning, as coffee medicated a mild hangover from a kickass shindig the agonyzer hosted with his partners in crime to celebrate their success in a damn fine production of A Christmas Carol — my firefox went batshit and commandeered my morning.
Long story short, over the course of maybe a half to a dozen page loads, the thing just ground to a halt. It wouldn’t respond within the page or in the menus. It acted like took control of X, or at least of KDE, by seeming not to let you switch to a different window, but it was actually just slow, and once switched, you could move between all the *other* windows and terminals with ease. One thing it did leave me was the ability to close the program from the corner ‘X’, and it closed quickly and cleanly. I’d relaunch — no alerts, it was a clean close and didn’t believe itself to have crashed — and as the tabs from the previous session opened, it crawled to the same condition.
Repeat several times, closing out all but the standard dozen or so tabs I keep open 24-7, which I know aren’t likely to have any out of control scripting — no change. No change in safe mode, or after using safe mode launch to restore some program defaults. Try an apt-get upgrade (think “Windows Update”) on the system (running debian testing on a pretty old amd xp-1700), and a dist-upgrade (think “Windows Service Pack”). These installed a new enough firefox that I had to upgrade some plugins. Finally an install –reinstall on firefox, err, iceweasel. Rebooted after each of the last three. All without making a lick of difference.
Exasperated, I closed all the aforementioned always-open tabs, restarted one last time — and everything worked like a champ. Of course I immediately reopened all the same standard tabs, without a hitch.
So it doesn’t seem to have been the pages, but something with the browser’s cache of information about and controlling one or more of the tabs and their content.
As far as the awesomeness goes — well it *was* pretty impressive how consistently firefox reproduced my session tabs, through all those ups and downs and upgrades and even the reinstall. Even if it did suck that it had to reproduce whatever the hell was wrong in the process.
Internet Scavenger Hunt
by Jon on Dec.28, 2008, under Babble, General Tech, House & Home, Life, teh internets
Dear Internets,
Once again I must lament the lack of a furniture search engine providing advanced searches by dimension.
OK, so, I’m trying to find a tv stand. TV console might be a better description of what I want. Problem is everything I find is either wide and short, or tall and thin. I need medium-tall and medium-wide.
I like my tv to sit a bit high. So I’m thinking 30″ high at least. Give or take -2/+8 or so… Most everything I’ve found in that range are also around 30″ wide. But I want something probably between 40″ and 60″ or so … 45″ to 50″ probably being the sweet spot.
Open shelving for gear in the middle. I don’t really care what kind of small shelving or storage flanks the sides, but *some*, eg not an all-open shelf thing.
Probably black. Prefer wood, metal/glass/other considered. Straight lines, modern or classical
This “Low Cabinet with Sliding Doors – Antique Black” is sooo very close that I very nearly pulled the trigger — before I found precise specs for the interior space on another site, and found the interior shelves won’t hold any gear. You need at least 15″-16″ depth, and on the width, figure the devices are usually 17″ and you want some breathing room.
If the Kathy Ireland IMTL363 – Tribeca Loft Tall Console has a little cousin it could be a contender. But still, really looking for more open space in the middle, smaller utility shelves/drawers/doors/whatever on the sides. And, uhh, I won’t cripple the search with an exact price requirement, but, umm, not that much. Just figure I already broke the budget getting what goes with it :)
If anyone finds the winner I’ll definitely buy you beer. Two if I like you!
UPDATE: I might have found it. It’s a little more than I want to spend, but maybe not more than I can realistically expect. I’ll sleep on it and give it some time in the morning before I say go. Beer offer still applies if you happen to find the same one. In fact I’ll buy three just in appreciation of your accuracy :)
UPDATE2: OK, done deal, we have a winner.
Free To a Good Home
by Jon on Jun.22, 2008, under Babble, General Tech
Just a quick interjection here, can anyone use a couple of Dell T0529 compatible black ink cartridges? I’ve got two that were shipped to me by mistake. It’s a remanufactured knock off brand, but I’ve had good results with their epson products. If anyone wants ‘em, say the word.
The three types who understand binary
by Jon on Jun.15, 2008, under Babble, General Tech
A nugget of common wisdom in the world of computer programming speaks to the division of programmers into two basic categories (we do like things in binary…) — those who code because they love it, live it, and would be doing it even without the paycheck, and those who do it because someone told them it was good way to make a living. The former are generally considered the good ones, though I suspect management may recognize how the latter may have their uses.
I find myself somewhere in between, being a person who lived it and loved it until he was about 13 or 14 or so, a bit of a programmer prodigy — right up until I discovered the things that would really drive my life: music, literature, philosophy, film, politics, and parties — not necessarily in that order. I only came *back* to programming when I finally resigned myself to the need to make a living.
So, yeah, I’ve got more natural skills and code with more artistry than the latter, but have to bow before the former (which would include all my colleagues). This of course is why you almost never read tech posts from me. And yet why you will get this occasional one as I pat myself on the back.
OK, see, I’m in a position that’s actually probably perfectly suited for my particular point in the aforementioned spectrum. I started out here working as a maintenance programmer on some old code from the 90s. And while we have been working to replace that system with a modern architecture, we find we run up against its limitations more quickly than we can realistically port it to the new environment. And so at some point my job changed from *maintaining* the old code, to *transforming* it — rebuilding in place, creating a brand new system on top of the old data & schema, to solve the problems of today that can’t wait for the potential of tomorrow. As I paraphrased the other day to Cory, I liken my job often to that of a modern artist making sculptures out of garbage found in a landfill.
Anyway I’m just posting to rejoice in having finally solved a particular problem that’s plagued us from the beginning. See, the people who wrote the old code for some reason got it in their heads that a user would surely *never* change their email address, and pretty much built the entire system around the idea that an email address was the primary identifier — they made email address the primary key of the users table, and made it the link to just about every other table there is.
Raise your hand if you’ve only ever had one email address. What, no one? Well then, you see our problem.
It’s a problem that I’ve been thinking about for going on three years and which finally bubbled up to the top of my priority list this week. And after building and trashing a few different hacked-on schemes to add an email address table attached to the user, all of which had numerous ugly complications when it came to account logins, maintaining continuity, preventing hijacking, and a whole host of other issues — on Friday it came to me and I hacked out most of it in an exciting flash that hearkened back to those early days as a pre-teen teaching himself assembler.
It was so simple it was stupid. All I had to do was take a step back and redefine my terms. Create a new “superuser” table and store the superuser id as a foreign key in users. My “superuser” becomes what would be a user in a smarter system, and my current “users” table become the equivalent of an “email addresses” table. Everything works exactly as it has for probably 10 years or so, and when someidiot@yahoo.com wants to become someidiot@gmail.com, they do so exactly as we’ve always done, creating a brand new “user”. *I* know that both “users” are the same superuser, even if legacy code and the user-order-item cascade doesn’t — and my soon to be redesigned account manager program will only care about superusers.
Elegant and minimally invasive, yet turns the entire platform’s assumptions on it’s head and solves one of the biggest thorns in our side in about two days worth of coding. Maybe I’m still a real geek after all.
channels
by Jon on Apr.17, 2008, under Babble, General Tech, Music
Let’s keep on with the music posts, but make a sharp left hand turn: Howard Jones
I don’t want to overstate the case — I mean he’s not the Art of Noise, or Falco :) — but I always thought highly of him. Loved New Song, liked many of the others. Certainly enough, at least, that I paid attention to an early Keyboard Magazine interview, where he mentioned a practice that struck and stuck with me. He described some program or other mechanism he had that allowed him to color, thicken, and “humanize” his sounds with random subsonic elements that duplicated the main tone at varying detuned pitches.
Now I’m sure that these days you can download some ungodly number of cubase/protools/whatever plugins that accomplish this sort of thing a thousand different ways in ten thousand flavors — and don’t get me wrong, that’s awesome. But I was more taken by — well I don’t know if philosophy, or maybe just aesthetic goal is proper — the very idea of using technology to its fullest, while at the same time subverting it, in the margins where the technology’s imperfections meet our own, in order to make it our own and make it real. Very attractive to a pre-teen hacker wannabe in the process of discovering his real muse. (And not a terribly inaccurate way of describing what I do now at the day job…)
But all that’s sort of a tangent. OK, so Sunday night, Kate and Karsten dropped by to help me smash a champaign bottle across the annual turning of my odometer. Now you’ll have to forgive the fragmented nature of the files my head kept from the night — the drives definitely crashed. Anyway, at some point I introduced them to my rig (and no, that’s not a euphemism), and I seem to remember Kate and I discussing the pros and cons of a mostly outboard setup (eg, sythns, drum machines, effects, etc, all in separate boxes running through a mixer) vs an all-digital/all-virtual system recording inside a studio software suite and/or a program like GarageBand.
And I’m pretty sure I was too wasted to have said anything intelligible about the subject, so let me try again here.
OK, well the thing is first of all I don’t consider it either-or; my boxen fed into a Cakewalk studio, where I would then mix in with digital sounds & samples on the pc. Of course, available quality on the pc side has probably gone up exponentially since then. Knowing this, if forced to choose either/or then I would choose the all virtual path in a second. My setup actually did evolve from such a virtual setup — but Cakewalk for DOS on a 386 only gets you so far, even when you smpte sync to a four track for the live sounds. So I started collecting boxen :)
But by the time I got to a place where I had a reasonable access to both paths — well I’d spent a lot of time sculpting sounds with the tech I had. And one of the things that I came to believe is that every physical thing which touches your sound — changes it. Every wire, chip, jack, cable, diode… every single thing changes the sound, in the unique, if maybe or almost imperceptible way that a unique object can and must.
Two synths of the same make and model made to the same specifications playing the same note programmed to the exact same settings will not sound the same. Maybe not so much that you can hear it, but absolutely enough that when they combine, they make a thicker, more imperfect sound than merely playing simultaneous digital copies of the same .wav from the same source.
In the end I found that most music produced within and from a single homogeneous environment sounded to me like it had a certain “sameness” to it. Almost like a technical frame I could always see wrapped around the sound. Which is very good, for many purposes. But it’s not punk rock. I wanted to try and punch through the walls of those frames. More real world components equals more chaos, more entropy — more noise, and more humanity — to channel back into the sound. More imperfection.
Then again, the computers really are much more powerful now..
Well the most important thing I think is that I got all the way through the Howard Jones post without saying anything about “No One Is To Blame”. I suppose that’s probably a good thing…
google dissed
by Jon on Apr.07, 2008, under Babble, Food & Beverage, General Tech, South Nashville
My part of town is totally on the grid — except for my street, which they decided to skip for some reason. It’s like getting picked last for kickball all over again. But if you could turn down this street here, you’d literally be a stone’s throw away. Well, if it’s a small stone and you’ve got a good arm.

Oh well, at least some people are giving our quaint little barrio some respect.