Ethan's blog

A Poor Coder's Devel Themer Port for Drupal 5

Ethan's picture

Let me start by saying I’m not proud of this, it is one of those awful awful hacks which I should be ashamed of and appalled that I would even consider, one of those hideous violations of every coding standard known to good coders throughout the world.

What is this horrid, monstrous bit of code hackery I’m referring to? It’s a simple hack to the theme function which provides a very rudimentary version of some of the theme-level information so elegantly and profoundly usefully exposed by Moshe Weitzman’s Devel Themer module. For various reasons, this hack actually isn’t that egregious; for one it is ONLY FOR USE ON DEVELOPMENT SITES, and therefore does not all into that more loathsome category of coding dark secrets which are injected into codebases in the 11th hour to make Drupal conform to non-Drupal-tuned functional specifications. In addition, the hack allows custom processing of theme output to be included in the info dump for themed blocks, and therefore makes incredibly arduous tasks like finding the source of a missing </div> tag a great deal less awful. Let’s face it (with relish): sometimes hacking core is just the best way to debug difficult problems.

So, enough stalling, just what is this horrible, awful, shameful hack I’ve devised. Well, it’s anticlimactically simple, actually. Just insert the following code into the function theme() declaration in theme.inc just above the return call_user_func_array($functions[$function], $args) call:

Node Import Part 0: the prequel

Ethan's picture

I thought I'd share some lessons learned in the node creation wild as a follow-up to Tom's recent post surveying the options available to prospective content importers who need to get a slew of nodes into Drupal from some far off place such as the land of flat HTML, custom CMSes or even the fabled Drupal 4.6.

For a very exciting upcoming site we had to import a few hundred old blog posts from a Drupal 4.6 install, along with 30 authors and around 2000 taxonomy associations. While these numbers are nowhere near as big as content migration figures can crawl, the complexity of the data structure was multiplied by the specific requirements of the various node importing schemes available in Drupal. This multiplicative factor yielded a somewhat dizzying array of alternatives that had to be evaluated, with the vast majority of them leading down paths that involved exporting nodes, importing with old legacy data attached then iteratively importing the author and taxonomy data one piece at a time using custom scripts and translation tables.

Scary.

Synergy: more than keyboard sharing

Ethan's picture
Tags: 

I have recently started using synergy to control my Mac and PC using a single keyboard and mouse. Synergy is a pretty impressive piece of Open Source software: it’s impressive enough that it can use a standard LAN network to share input devices between computers. What I didn’t realize until setting it up was how much more it can do.

While Synergy is fairly easy to set up, being a geek-centric piece of open-source software it requires some editing of configuration files and the like (though on Windows machines a straightforward GUI is provided to facilitate this). Configuration files specify not just what machines are going to be controlled and how their monitors are laid out in physical space, but also allow for a plethora of configuration options. While many of these options are basically just advanced setup parameters, there’s one class of options that makes Synergy incredibly powerful:

Through Synergy’s configuration file one can map keystrokes entered while controlling any machine to (not necessarily identical) keystrokes on a specific machine!

first post: how the shell made me go !h:7 !!

Ethan's picture
Tags: 

Hi I'm Ethan, the new guy. This is my first post, but beyond that brief bio and the unequivocal denial of any claims that I don't change my shirt on a daily basis, this post isn't going to be about me.

It's going to be about the totally off the hook tricks I leaned about the "previous command" shell shortcuts I learned today from this post and how they totally rocked my world a second ago.

So here's the situation: I downloaded a file and couldn't remember whether it was a zip or a tarball, so I ran this command:

   tar -xzf ~/downloads/google-sitemap-generator.3.0b7.zip
 

Why did I try to unzip a tarball, you ask? Because I'm lazy, and when autocomplete says "press enter", I ask "how fast"? Needless to say, the result was some mumbo-jumbo that I'm sure must have had ample amounts of bit-level impatience buried somewhere underneath it.

Remembering the tricks from that post I tried this:

   unzip !^
 

I was thinking that maybe the first argument (referenced by !^) would be recognized as the argument after the flags. But no go, it resolved to unzip -xzf

Now I had a bit of a dilemma: I couldn't use any more of the cool tricks because they all referred to the command prior to the last...unless. What if all the argument referencing commands could be prefixed with a pattern!?! Sure enough, this gem worked like a charm...gem...:

   unzip !tar:2
 

Which basically reads unzip {the second argument of the last command matching the glob-string 'tar'}

To my total, complete astonishment it actually worked. Brilliant.