February 4, 2012

I'm jealous of Rails 1.1

tracks I'm jealous of Rails 1.1Wow, I have to say that I’m getting jealous of the [tag]Ruby on Rails[/tag] framework. Their new release looks simply great.

I read the Signal vs Noise blog, despite the fact that I’m not a Rails developer, since they are so darn smart and inspirational. Looking over the list of new features in the latest release, I find myself thinking that they "get it". They add things which provide real value to actual web developers.

The new features don’t have the Java-reek of "design by committee" or "let’s over-engineer so that we’re enterprise-class", they have the flavor of features added because they are needed, wanted, and will be used. It is a lot of the same reason I love [tag]Django[/tag]. Both projects clearly come from an environment where if the feature isn’t needed for something real, it isn’t getting added.

The sweetest 3 new features

  • JavaScript in Ruby, RJS. Taking a look at JS code before and after RJS, I have to say that I am green with envy.
  • Accept-driven responses. A brilliant hack, they are now using the HTTP "Accept" header to drive controller output.
  • Integration testing. Anything which adds more hooks and more ease of testing is good in my book.

I’m still not a convert. If I had the time, I might give it a whirl, but for now I’m going to stick with Django. That doesn’t mean I won’t be raiding Rails for ideas though.

Django and multipart emails

handshake 2 Django and multipart emailsAs part of the Django storefront app I am writing, I need to send multipart messages. The base Django mail functionality doesn’t seem to do this, at least not with my version of Python. It could be a Python bug (actually I am pretty sure it is a bug, and I’m going to followup on that as well) but I need it solved now, not at the next point release of the language.

In the meantime, I’ve made a multipart aware patch and submitted it to the Django project. They accepted my last patch so quickly, I’m curious to see whether this more "debatable need" one will be accepted.

[tags]django,MIMEMultipart[/tags]

Django and authenticated smtp

handshake Django and authenticated smtpI just sent off my first patch for Django. It adds the ability to send mail via SMTP servers which require authentication. I need this for Dreamhost, which has authentication on its mail servers.

The modifications were simple, and the code I was modifying was refreshingly clean. Better yet, the Django project site gives easy and clear instructions about how to contribute. So, I’m feeling very good about the project, the ease of contributing, and the maturity of the code.

Update (next day): They accepted the patch and merged it into the trunk of the dev version. I updated SVN and it is all there. That is the fastest response ever for one of my patches to be accepted into a public open-source project!

[tags]django,dreamhost[/tags]

Site Updates

happy Site UpdatesA quick site update. I’ve added a couple features.

First, I’ve added “email this post” functionality to every article. Now you can send anything I’ve written to a friend with one step.

Perhaps more importantly, I’ve added a “Related Posts” section to every article. At this point, the related posts are only shown when you view the article on its own page, not on the front page. I’d love feedback about this. Should I add it to front page articles as well? Is that too busy?

Related Posts plugin modifications

adapter Related Posts plugin modificationsI’ve been delaying using a related entries plugin because it didn’t fit with my normal way of posting. See, it uses a WordPress custom field "keywords" to do its matching. That’s OK, but I already have all my posts marked up with inline keywords, for the Technorati plugin Simpletags.

So, when I have an itch for long enough, I scratch it. So, I’ve written an extension to the related-posts plugin which reads keywords from the post text inside [tags] [/tags] markers. In other words, it leverages the use of the Simpletags plugin. You can see it in action by clicking the post title of any entry on this site.

I’ll be submitting the code additions to the original plugin author, but I don’t know if he’ll take them, since it is sort of an edge-case. In the meantime, feel free to comment here.

Here’s my modified plugin: Related Posts Mod 2.02.

Related posts

Technorati Tags: , , ,

Endicia for Mac Review, initial impressions

snail Endicia for Mac Review, initial impressionsI’ve been shipping a lot of packages lately. It was a big pain, and now it is not. That’s my basic review of Endicia for Mac.

Manual shipping

When I first started shipping, I’d manually label each package. My handwriting is terrible, so it looked like a retarded monkey wrote the label, and I wasted several bubble-mailers by boneheaded misprinting. It took more time than you might think to label each package. But that time paled next to the time it took to stand in line at the Post Office to mail the things. Ouch.

Automated shipping – the equipment

I purchased a 25-pound USB scale for $85 from Endicia. It works very nicely from within the software. Just put the package on the scale and click “weigh”.

My label printer is a Dymo 400 Turbo from Label city for $109, and I bought a roll of three-part internet postage labels #30387.(Here’s a coupon Endicia for Mac Review, initial impressions) for $15.

It all worked right away on my G5, with no fiddling about, pleasing me greatly.

Endicia Account

To use Endicia, you create an account and pay a monthly fee. I’m using the “premium account” at $15.95 per month. This lets me print unlimited postage, creates customs forms for me, and gives me access to the cheaper-than-USPS Endicia insurance.

Then, I attached a credit card to the account and bought an initial pool of postage. You can add more at any time from the website or from the software itself.

The software

I am pleased to say that the software has performed flawlessly so far. I’ve shipped about a dozen things over the weekend, and been pleasantly surprised at how seamlessly it works.

  • Get an order, copy the address from the confirmation email
  • Paste into Endicia’s address area.
  • Hit validate, this reformats it according to what the post office in that country wants as a standard. (Very helpful indeed.)
  • Select the type of shipping.
  • Click “Weigh”.
  • Put a note in logging area about what this is (so you can look it up later). There is an area for an order number as well.
  • Click print, then confirm on the next page
  • Drop the packages in the bulk-mail bin and the post-office and skip the long, slow lines!

Conclusion

This wonderful, easy-to-use system has cut my shipping time down from 4-5 minutes each to less than 2, and made the drop-off part almost instantaneous. I ship every day, so that alone is saving me 10-30 minutes. Add up all that time savings and you’ll quickly see why this is a complete winner of a setup for me. I rarely give such unreserved recommendations, but so far they’ve really earned it.

[tags]Mac, Endicia, label printing, dymo, usps,reviews,online postage[/tags]

XML Is Java's Scripting Language

troll XML Is Java's Scripting LanguageGreat article at Lesscode.org, responding to Gosling’s dismissal of scripting languages.

Usually, I ignore attacks like Gosling’s as not worth my limited time and attention. I love Python, and it really doesn’t bother me when the ignorant attack my language-of-choice. This article is better than the original by orders of magnitude, due to its heavy linking and its excellent reader commentary.

My favorite quote from the article is: "this is why XML is used so heavily in Java for things like O/R mapping, dependency injection, configuration, build processes, etc. — XML is Java’s scripting language". It is actually from a reader comment, which is worth quoting in full.

But Ruby, Python, Perl, Smalltalk, etc. are not specialized scripting languages. They are general purpose programming languages. I believe one of the reasons the term “scripting language” has stuck with them is partially because it’s become so common to create mini-languages (i.e. DSLs) in dynamic languages that are specialized for certain tasks. So it’s sometimes hard to separate the specialized pieces from the general purpose pieces. Contrast that with static languages, where you are forced to create a completely separate “scripting language” when you need to provide a constrained/specialized language (this is why XML is used so heavily in Java for things like O/R mapping, dependency injection, configuration, build processes, etc. — XML is Java’s scripting language). In dynamic languages, you are generally not required to leave the core language to get that specialization: you use techniques like meta-programming and DSLs or just include/require/use some designated file at a designated point and let it do it’s thing with the API.

Coding Flow and Techniques

mattock Coding Flow and TechniquesAny programmer will tell you that one of the characteristics of really getting into a programming "flow" is that your mind is completely engaged. I think of it sort of like a stack. I have all these small tasks which need to be accomplished, and which can’t be put off because they’ll block my progress.

So, I stick the current task on the top of the mental stack, and do the little diversion. The diversion might have more diversions which get stacked on top. But pretty much I do them in last-in-first-out order. For example, today I was programming an email confirmation system in Django.

    A stacked task example

  • I was testing my form template, and wanted to make it both pretty and XHTML valid (Stack: 1).
  • To do that, I needed to make a base template which the confirmation forms would extend (task 2).
  • The base template really should use CSS for ease of formatting, and for standards compliance (Stack: 1,2).
  • Oh, but CSS in Django really should be served by the media server, yet I haven’t mapped the media URL on my development server. I should do that now, or else it won’t resolve (Stack: 1,2,3).
  • Start NetInfo Manager, map it (Stack 1,2,3,4-complete).
  • Add the media url domain to Apache as a virtual host (Stack: 1,2,3,5-complete).
  • Bounce apache, test media domain (Stack: 1,2,3,6)
  • Troubleshoot why apache didn’t bounce properly – bad vhost line (Stack 1,2,3,6,7-complete)
  • Bounce apache, test media domain, success (Stack: 1,2,3,6-complete)
  • Test Django CSS from template, hard coding media URL (Stack: 1,2,3,8-complete)
  • Oh, but hard-coding is foolish when the media URL is stored in the settings. Is there a way to use the settings? (Stack: 1,2,3,9)
  • No, but I can write a templatetag. (Stack: 1,2,3,9,10)
  • Lookup template tag docs, write one to do media URLs for me. (Stack: 1,2,3,9,10,11-complete)
  • Test new template tag. (Stack: 1,2,3-complete,9-complete,10-complete)
  • Test base template with new tag. (Stack: 1,2-complete)
  • Test form, extending base template. (Stack: 1-complete)

If you are a programmer, you’ll recognize this style of thinking. If not, and you’ve managed to read this far, perhaps you’ll understand a bit more why we get flustered when people walk up to ask questions. If a programmer is managing a stack of tasks 5 or 6 items deep, it gets easy to lose the thread of what is going on.

I’ve been working for years at getting better about interruptions. I love the flow state, but I think that we programmers make it too fragile when we try to keep everything in our head. The thing is that always seems like you are almost there, so the time to write down anything about your stacked task is a waste of time. I’ve been fighting that tendency, with varying degrees of success.

For quite a while, I’ve been doing this mostly by keeping an engineering notebook. That way I can scribble notes which will – sometimes – lead me back to the path if I get distracted. Today I tried a new technique, which was to use the excellent little app Sidenote for OSX. It is just a little "Sticky" style note taker which lives on the side of your screen. It minimizes when not in use, and it autosaves all the time. That’s a nice bit right there, you don’t even have to think about saving.

Basically, I’ve started using it for two things. 1) To track my "stack" and 2) to track needed/possible future refactorings. I haven’t gotten fully in the habit yet, but I had a six hour long coding-flow session today, and Sidenote was a very helpful part of that. The stack is empty and I have one refactor to do. Plus, I got to code my heart out, which always feels great.
[tags]Sidenote,flow,coding flow,productivity,programming[/tags]