SILT: Reverse templates, the pixels, and swig

The Final Frontier

In case you've been wondering where I've been. (space, duh.)

Wow, it has been a while. Sorry for the silent treatment, it’s been a busy time. I’ve been learning lots, so hopefully I’ll process that queue in a blaze of consistency. Bring on the MEAT:

  • Recently I had to do a whole load of data processing. Not a one-time deal, but good old XML processing for API integration. It occurred to me that just as Web 2.0 and its myriad frameworks have brought a new age of templates, it seems that there should be a complementary reverse template. As in, I specify a template, and a string, and I get a map of variables back (as opposed to template+map = string). This would seriously be the most beautiful thing.
    And as it turns out, for once, Perl schools all other languages, because it has it. Template::Extract. If someone made this happen in Python and/or PHP, I would probably engage in an illicit tryst with them. Until then, I have to do xpath-style stuff. Which is fine, I guess, but you’d agree that it’s harder to read and maintain.
  • Back when I started doing serious web frontend stuff last summer, I was pretty sure the pragmatic among us were on the same page: px is the way to go for CSS. Everything pixels. em was a hack for IE6, and we’re done with that now, to the point that I’m even exasperated by dead-horse pages like this.
  • For my next project, which will be depriving y’all of blog posts soon enough, I’m planning on using the crap out of swig. Use it to call C/C++/Objective C from basically any scripting language (in my case Python, again). I’m not yet sure of its advantages with PHP as I use it, because it’s really not hard to write your own C++ PHP extension. If all goes well, I’ll be following up on this.

OK, three is good. I save the rest in drafts as they come, in case you were wondering.

Hit and Run: Windows Mobile Emergency

I had to call the police recently. A combination of laziness and problem urgency led to me dialing 911 on my Windows Mobile-powered cell phone.

When you dial 911, Windows mobile flips the FUCK out. Despite the Vibrate setting, my phone begins a very loud and very noticeable series of beeps as it enters “Emergency Mode”. In this mode, you cannot dial any numbers that are not emergency numbers, apparently. What programmer was sitting in front of Visual Studio, mashing away, thinking, “I’m saving lives here guys, with these beeps, these loud beeps.” Woe to the bank teller or kidnappee who tries to get wise. Here’s some wisdom: anything not Microsoft.

Sent from my iPhone


^ not really; do you think I’m made of money and data plans? Also, the thing that pushed me over the edge in writing this post is the fact that my phone has not rung since this. I just miss the call. Yes, I restarted it several times.

Hit and Run: Avatar

It’s Fern Gully plus Dances with Wolves plus Halo (for the space marines). Yes, even in 3D, not much monumental other than the cost and the advertising effort. You would think with a multi-hundred-million dollar budget they could afford a custom font, or at least a nicer font than Papyrus (which was dead the day they invented ecards).

Obviously I don’t speak for the masses; 83% on Rotten Tomatoes and a ton of Facebook statuses indicate that people are pretty satisfied. Put simply, I spend too much time with computers to be impressed by this middling, overmarketed effort. What excites my brain and arpeggios on my heartstrings are personal efforts, far ahead of their time, like this one, Vol Libre.

Not the Last Airbender

Vol Libre plus Papyrus = Cooler than Avatar

Made in 1980 by one man, the current Chief Scientist of Pixar, but then just a faceless engineer for Boeing working on a passion in his spare time. Talk about unobtainium.

Geek Code

Remember this old bit? Well, I figured it was about time to generate my own. Gentoo users just emerge app-misc/geekcode and run geekcode. There’s also an online generator you can google for. It takes around 15 minutes, and transports you about 15 years into the past.

Here’s me:
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GAT d- s+: a-- C++ UL++ P- L++ E W+++ N o- K w
O-- M-- V-- PS PE- Y PGP t++ 5 X- R !tv b+++ DI+++ D+
G e++ h* r y?
------END GEEK CODE BLOCK------

Here’s a geek code interpreter.

SILT: Google’s Latest Gifts to Coders

This lady on the netbook is almost certainly perusing Google's coding gifts while being frustrated with Gentoo. She gets me. I took this photo at PayPal's Innovate conference a couple weeks ago and it's already my second-most popular photo on flickr. I dedicate this post to you, free netbook lady!


Work and life are trying to keep the SILT posts down, but no way, josé. Fight the power.

I don’t know if these are really the latest, but they’re pretty recent and boy are they handy.

  • I was thoroughly impressed by Google’s properties’ APIs, as demonstrated at the Google Code Playground. Seriously, there’s an incredible amount of data/functionality there.
  • I cannot wait to have something cool enough to code in Go, Google’s new programming language. It’s everything C++ could have been (in a much more perfect world). It mixes everything one could want from dynamic languages (e.g., Python) with the performance and compile-time checks of compiled languages. I’m really cheering for this one, hoping that Google’s backing brings forth a plethora of libraries and frameworks to leverage for practical purposes. Qt bindings or a web framework is what I’m seeking.
  • I’ve basically been relearning Python while using it for the biggest project I’ve done at work, yet. It’s really killing me in spots where there is some unwritten “Pythonic” way of doing something, and I’m met with implicit resistance in doing it the way I had thought made sense. Enter Google’s Style Guides (Python | All). It may not seem like much, but it really helps in those situations when the decision seems arbitrary, but somehow like you might regret making the wrong choice. The simple things, guys. Fundamentals.

As for things I am less grateful for, I am very frustrated with the fact that Gentoo is still on PHP 5.2, because 5.3 has a lot of sweet features, including much better crypto support (of which I am in dire need currently). PHP 5.3.1 is already out, and I can’t get 5.3.0? You guys call this bleeding edge?

Photography Hosting Strife

I realized with disgust that, having written a post about photography, I was more obligated than ever to find a picture to attach to this post. This is a totally random shot I got from the PayPal X Innovate conference, currently available on my Flickr account.

I take pictures. Normally, I process them, and stash them away on hard drives, only to post a few select shots some weeks later. But lately people have been wanting me to take pictures and put them up for public viewing post haste. Facebook is utterly unmentionable, that goes without saying; butchering photos with a sickening amount of compression and resizing to 614px on the long side. I have a Flickr account (it feels way cleaner and more respectable than DeviantArt), but I really dislike Flickr’s interface when it comes to sets (and the “All Sizes”/sizing thing is horrid). SmugMug is better but still not that good for my purposes. Flickr has a nice community and clean, if not very usable, interface. I just feel bad using it for an all-purpose photodump.

So I’ve been thinking about starting to use Picasa Web as my photodump for large sets of images. To me, Picasa feels pretty amateur, but at least others can easily navigate forward/backward, zoom-in, do other NORMAL things. I have frequently had to show others how to do this stuff with Flickr. What solutions have you all found? Anyone else run into the angst of diluting their portfolio with obligatory images? Does my Flickr portfolio/Picasa photodump solution sound sound?

Happy Birthday, Superdrivel!

The G20 hits 50,000 miles

Speaking of birthdays, the van turned over its 50,000th mile recently. It's doing great, though we both almost died while I took this picture.

Celebrations all around! Superdrivel turned 1 on October 24th.  Of course, I didn’t really start bloggin’ on it till January, and even then it was just to whine about blogging.

DID SOMEONE SAY PARTY FAVORS? HOW ABOUT SOME STATS?!!

  • 33 posts (prior to this one) – that’s 25% more than every other week!
  • 64 non-spam comments (almost 2 per post!)
  • 69 spam comments, all but one of them blocked automatically by Akismet.
  • Top post (by pageviews) – the iron gym is great (~1200 views)
  • Top post (by comments) – Is Gentoo dying? (14 comments)
  • Top search topics (paraphrased) – “iron gym”, “the a-team van“, “gentoo”, and “benjamins
  • 28 Google Reader subscribers – I missed the FeedBurner boat, so it might be even more.
    • I ❤ all of you. I would feel pretty silly if no one read this stuff.

Lately, I’ve also been averaging around 20 hits per day to the blog in general. Not that traffic is important, just wanted to let you know you’re not completely alone in this remote corner of the intermist.

PARTY IN THE COMMENTS! Now’s your chance to tell me how to be a better blogger/friend/person!

LESS and incron: CSS at its finest

less is, once again, more.

less is, once again, more.

Web development is full of challenges. That’s my nice way of saying writing CSS blows. CSS is powerful, but at the cost of being too fine grained and low level for easy development. It’s like the assembly of web design. Other developers are all-too-aware of the situation and have come up with a few solutions, including CSS frameworks, which reduce the amount of from-scratch code and provide a system (e.g., Blueprint or the 960 grid system), versus the freeform mess of raw CSS, and CSS extensions, like LESS, which is the topic of the day.

Act One: L-E-S-S spells bliss

If you aren’t using something like this yet, you might as well be punching yourself in the crotch every time you code.

I have also messed with Sass, which was not as “Syntactically Awesome” as LESS, and xCSS, which was overkill (but I might revisit it later). LESS is good because:

  • Any standard CSS file is a valid LESS file – easy to only use the features you need
  • Just as powerful as Sass, offering variables, functions, nesting, CSS-specialized math operations
  • Aptana CSS highlighting works great:
    1. Go: Window->Preferences
    2. General->Editors->File Associations
    3. Add file type: *.less
    4. Add editor: Aptana CSS Editor (right at the top)

I mean, look at this syntax:

@left_column_width: 300px;
@column_margin_width: 15px;

/** Palette **/
@light_blue: #d0dae3;
@pastel_blue: #7492ac;
@med_blue: #1e5d97;
@dark_blue: #0b3c68;

@light_orange: #f6b860;
@pastel_orange: #dfab62;
@med_orange: #e9951f;
@dark_orange: #a1630c;

/** Colors **/
@top_nav_color: @light_blue;
@top_nav_hover_color: @light_orange;
@header_color: @pastel_blue;

#header {
	clear:both;
	float:left;
	width:100%;
	border-bottom:1px solid @dark_blue - #111;
	background: @header_color;
	padding-bottom: 12px;
	margin-bottom: 7px;
	
	.page-title {
		float:left;
		clear:none;
		display:inline;
	}
}

/***** Two column layout a la   *********
****** http://matthewjamestaylor.com/blog/ultimate-2-column-left-menu-pixels.htm  *****/

/* column container */
.colmask {
	position:relative;
    clear:both;
    float:left;
    width:100%;			
	/*overflow:hidden;*/	
}

/* 2 column left menu settings */
.leftmenu {
    background:#fff;
	overflow:hidden;
	.colright {
	    float:left;
	    width:200%;
		position:relative;
		left: @left_column_width + (2 * @column_margin_width);
	    background:#fff;
	}
	
	.col1wrap {
	    float:right;
	    width:50%;
	    position:relative;
	    right: @left_column_width + (3 * @column_margin_width);
	    padding-bottom:1em;
	}
	
	.col1 {
	    margin:0 @column_margin_width 0 (@left_column_width + (4 * @column_margin_width));
	    position:relative;
	    right:100%;
	    /*overflow:hidden;*/
	}
	
	.col2 {
	    float:left;
	    width: @left_column_width ;
	    position:relative;
	    right: @left_column_width + @column_margin_width;
	}
}

Now you have an easily customizable two column layout and color scheme. Change your values in one place and they gracefully propagate. If you wanted to change the colors or column width before, you would have to change dozens of values. Really, stop what you’re doing, change your CSS file’s extension to .less, and become a happier person.

Act Two: Incron

So the only problem that I ran into is the bump in the workflow: compiling from LESS to CSS. This is where incron comes into play. Incron monitors files for changes and can trigger actions as specified by you with a cron-like syntax we can all love. I have a little Gentoo development box I use; I put incron on it and set it to run lessc whenever my LESS file changed. Just install/emerge incron, run incrontab -e and add one line:

	/path/to/less/files/mystyles.less IN_MODIFY lessc $@

Now you’ll have a file called my_styles.css and everything will be hunky dory. Of course this could easily be extended to do more powerful things with your styles, like move them into the right place or give them fancy names or version them or whatever. The potential here is also not limited to LESS, so consider it an investment. If this intrigues you, I think this tutorial should be all you need for now.

Well, web development is a big basket of ugly and this only addresses one aspect. There’s still cross-browser grossness and JavaScript debugging horror. But LESS helps. LESS helps.

Hit and Run: Google Android

Google is awesome and Android is a great concept: a really lofty ideal that pretty much only a giant like Google could have a hope of realizing. When mobile Linux didn’t take off on its own and it started to become clear that there wasn’t going to be a large scale open-source mobile platform, they acted with insight and decisiveness, announcing Android in 2007, and first releasing it in 2008. Now here’s why I think they’re going to blow it.

I recently sat down with the 'droid for some hard-hitting back-and-forth (forever)

I recently sat down with the 'droid for some hard-hitting back-and-forth (forever)

Android is an operating system, but not generally used by manufacturers in unmodified form. That’s because manufacturers want to differentiate their hardware and first-party software offerings. If they want to compete, they pretty much have to. I would say this is akin to Linux splintering off into a million flavors; each flavor has its own App Store equivalent and its own community for making sure that App Store works. Gentoo doesn’t readily work with apt or yum, but the Gentoo community keeps Portage working. Same goes for Ubuntu or whatever. Developers don’t worry about their package working on bizarre distros because there’s a community for that.

Manufacturers mess it all up by making their own flavor and expecting developers to support it. They’ll tweak or leave out functionality and still call it an Android phone. Google wants Android to get popular like Linux (moreso, probably), but it won’t happen because everyone keeps passing the buck on keeping software running seamlessly across hardware. I don’t see how Google can regulate, or how developers can keep up, so it comes back to the manufacturers. Remember manufacturers are the ones who couldn’t afford to develop a decent operating system of their own in the first place; they’re inherently greedy and they suck at software. I foresee a rough road for our boy Android.

SILT: Fences, Pastebin gone crazy, networking gone mad edition

Augh, I battled some large networking demons today to get a Gentoo box to have multiple MACs and static IPs. Also, it would seem some .NET/Windows developers are only a few years behind my brain.

Fences in play at work

Fences in play at work

  1. Today I got around to installing Fences 1.0. It’s an application to organize your desktop by functionally giving you icon groups. It’s kind of like being able to have multiple folders open in the background. This is all relevant because this is one of the first items on my software-writing to-do list that I tried to implement.
    Actually, it was #2 after writing an online to-do list, like Remember the Milk, except theirs doesn’t integrate with Checklist for the Palm, like I had started to write (I got as far as reverse engineering and writing a parser and minimal editor for Checklist’s binary format. It’s at once freeing and frustrating that 99% of the ideas I come up with will be implemented by someone else, and a good portion of those implementations will be too good for me to challenge. I gave up on Windows desktop development after a summer of .NET gross-out.
    BTW, pretty sure KDE4 has this.
  2. This link summed up how to get multiple IPs in the best way. It’s pretty much a quick primer in using ifconfig to set up your network card in bridging mode. The link specifies ubuntu, but it worked on Gentoo (and should work on all modern distros).
  3. I installed a pastebin over the weekend for internal use at work. I used the tarball made available at pastebin.com. It took quite a bit of modification to get it working the way I wanted to, however. Most importantly when using the "file" storage engine, it actually does not run, dying with an error about follow up posts. The solution is to actually dig through the code and comment out the die() call, then set the $post["followups"] = array(); inside the isset($post["followups"]) if clause. I realize the explanation is kind of hazy, if you actually run into this problem, let me know. In pretty much all othe respects it’s a great piece of software, and the perfect balance of things I was looking for in pastebin.