Where Are The Wise Men?

Mike's Ramblings

Slicing Some Python With Emacs

| Comments

I have a new job and it's quite probable that I will be doing Python for a lot of it. Which suites me just fine.

. . . except that I've been out of the loop in a while. Sure, I have written some Python in the past five years and [some of it has been substantial][] but I feel out of the loop. Most of my simple scripts have been done in good ol' Emacs and bigger projects have been done in [Intellij IDEA][] with [their amazing Python plugin.][]

As I started at the new digs, I installed Intellij on my shiny MacBook Pro, turned on Emacs mode . . . and was underwhelmed. I forgot that Emacs mode in Intellij on Mac leaves a lot to be desired -- C-Del for Cut, Alt-P for paste? Ugh. A quick search shows that [I'm not the only one complaining, but it's not fixable.][]

I thought about Emacs and what I would miss about running things in Intellij IDEA. The biggies were:

  • Syntax checking
  • Running unit tests
  • Auto-refactoring (Extract Variable, Method, etc)

These are things that are supposed to separate an IDE from a text editor. However, Emacs is an elegant weapon from a more civilized age. So the hunt is on to see what others have did while I was on my hibernation from Python.

I've tried to use the [Rope library][] in the past and found it hard to setup. But I did note that it's still actively developed and so I tried find to some example configs to steal borrow from. That's when I found Gabriele Lanaro's excellent [emacs-for-python][] collection. It included Rope, [YA Snippet][], and other goodies, all configured to work together in harmony.

I forked it, cloned it, and had a few problems, so I fixed them and Gabriele merged them back in. It still didn't have unit test support, but I found [nosemacs][], which runs [Nose][] on the Python unit tests.

In searching for something else, I stumbled into [virtualenvwrapper][], which are some helpers around the most excellent [virtualenv][] utility, which creates a clean environment for Python development. These are used in emacs-for-python, so I put it in as well. [I then stumbled into this post,][] which explains how to use the hooks in virtualenvwrapper to control Emacs. Woot!

So now my workflow is like this:

  • type 'workon something', which will put my prompt in my "clean room" Python environment for the project. My Emacs has also switched to that environment, including using that version of the Python interpreter.
  • In Emacs, type C-c m, which will run and report on all my unit tests in my current module
  • In Emacs, type 'C-c r ` to extract a new variable. Other commands exist for class, method, etc.
  • type deactivate and my prompt moves away from my clean room, and my Emacs leaves too.
  • when I go back to work on something Emacs will remember the last buffers it worked on.

I put all these changes into my branch of emacs-for-python, and Gabriele has already pulled them in. They are available in HEAD on [emacs-for-python][]

Master Foo and Corporate IT

| Comments

An acolyte found Master Foo meditating in his garden, sitting under his favorite tree. The acolyte waited until he was acknowledged. The Wise One did so, by asking what was troubling him.

"Why is it that Great Developers generally don't work for Corporate IT? And, when they do, they leave after a short amount of time and become contractors or work for a software-only shop?

Master Foo leaned against the tree, thought for a minute and begun to speak:

"Corporate IT is like a large city that had a great amount of cars. Everyone was upset with how bad the traffic was -- cars drove too fast, people were injured, it was horrible.

"A man worked for the city leaders and he was really good at solving problems. So the mayor put this man in charge of fixing the traffic problem. The mayor told everyone do to what the new Head of Traffic said, without question or hesitation.

he has only ridden in one a few times. No one asked him if he knew anything about cars. But the money was good so he took the job. He would tackle it like he did all the other problems -- by looking at data.

"As he looked at the data and reports that people gave him, the Head of Traffic noticed that a lot of accidents happened at stoplights. Not only did people get hurt in those accidents, but they delayed traffic. So the problem was simple -- cars needed to stop when the lights were green as well as when the lights were red.

"And the people that worked in the Traffic Department were perplexed by this but they were told to obey without question. So they posted the rule and told the police to enforce it. The police were also perplexed but they were also told to do what Head of Traffic said, so they started issuing tickets when drivers went through green lights.

"Obviously the people in the city were angry about this -- it took even longer to get from place to place! But, as more and more people stopped at the green lights as well as the red ones, they did notice that it was safer. So the citizens stopped complaining and just left much, much earlier to get to their destination.

"Of course, there are always people that have to get around the rules. Some started walking, and that was faster most of the time, so more people started doing that. And, soon, accidents were happening there. So the Head of Traffic was called on again, to address the problem. He first said no one was allowed to walk along the street, so more people rode bicycles. And the there were more bike accidents, so soon the law was to not ride bicycles anymore. Then people started on unicycles and laws were made there. It just went on and on and on.

Master Foo then asked, "Who has the most guilt in this city?"

The acolyte quickly answered, "It is the Head of Traffic, of course."

Master Foo said, "He actually has the least amount of guilt. It's not his fault he was given a job he knows nothing about."

Upon hearing this, the acolyte was enlightened.

My Holy Grail of Content Delivery

| Comments

I've been on a quest for a long time to figure out the best way to write and publish documents. It has been a quest that has taken me years but I finally have a system that I am extremely happy with.

What I wanted was to be able to write via Emacs (my editor of choice) and output to anything else. Want my document in HTML? You can have it that way. Want a PDF? Yes, I can. What is in Word? Though I can't stand the application, and I don't actually own it, yes I would like to be able to output Word docs without actually opening another application. Just writing it in Emacs, run a process on it, and the I have a Word document!

This has been nothing but a pipedream for a long time. At the beginning I tried to use this idea with [LaTeX][], and I could get the PDF output to look outstanding. The HTML output took a lot of work to get right, and I never got [latex2rtf][] working well enough that I could send that document anywhere else. So I had to figure out what else to use.

Then I started playing with [Markdown][]. I really liked the easy format, but it really only would output into HTML. With a bit of work, I could do a PDF (html2pdf or something like that ), but something to load up with Word? Forget it! And even the PDF looked kinda bad. The same thing with Textile and reStructuredText -- HTML and that was about it. I did prefer the Markdown format over LaTeX based on it's simplicity but I still haven't found my Holy Grail yet.

Just a few months ago I somehow stumbled on [Pandoc][]. I think it was on Google+, on someone's random post. I was floored when I read it: "Take a file in format X, run Pandoc on it, and get format Y, with varying degrees with X and Y?" This seemed like just what I was looking for!

But did it work as advertise? Yes it did! It understands everything about Markdown that I currently throw at it. To get the PDF conversation script working, it used LaTeX as an intermediarty so you have to have LaTeX installed. But Word? Not directly -- but it does have RTF support, which is even better (since it's more portable). It also does [ODT][] format, which means I can open up in LibreOffice and tweak for presentation if need be. The ODF output is better than the RTF output, in my humble opinion.

The biggest surprise I got was that it does conversions to [S5][] -- so I can do representations in Emacs/Markdown and be able to present with just a browser. I have done this and it works amazingly well.

One thing I haven't tried yet is that is also outputs to ePub. If it only did the closed Mobi format for my Kindle.

So, yes, if you are looking for a "write-once, publish to anything" scheme, you can't do any better than [Pandoc][]

2011 The Year I Learned To Fail

| Comments

As 2011 comes to an end, and I reflect about what over the year (which was a lot) and what I learned (which was tons) there is one thing that stands out. The one signal that God gave me over and over again, in tiniest details and in big, large letters was something simple, but took me a long time to understand.

It was that failure is OK. No, in fact, failure is a good thing. You can learn from failures, but you can't learn if you don't at least try. And, if you try, you may actually succeed.

The first sign of this was when I attended the Omaha Young Professionals conference in March. I really went to hear [Cory Booker][] but it was [Jason Seiden's talk][] that really spoke most to me. His talk was entitled "The Art of Failing Spectacularly". And it was about just that -- it's OK to fail, as long as you learn from it. But if you did something, at least you did something, as opposed to sitting on the sidelines, fearing what might happen if you live your story.

The next signal was from [Seth Godin][]. I had never really followed Godin before, but just after I heard Seiden's talk, I followed a link from somewhere about a free Kindle book. I love my Kindle and I love free. The book was [Poke The Box][]. And what was it about? Starting something, getting over the fear of failure. The same message came twice in six weeks. I'm now listening.

So I set out to, as Godin would say, poke the box. I was more careful at first at what I was going to poke. I work where the culture as a whole looks at change with a lot of suspect, but my management was open to a lot more change. So I started just doing stuff and making suggestions that were different, and feared. Most took, a few did not.

At my day job, I'm working with a team to replace an aging mainframe system. And we have been given some leeway on how to accomplish our end-goal. So I've been suggesting things that I would like to have done. Sometimes they are accepted, sometimes they aren't. And (uncharacteristic of me) I've started to push back on management when I think they have bad ideas or are pushing us in a direction that I feel is not quite right. Sometimes I win and sometimes I lose, but, more importantly -- I've won a lot of respect. And I find that I'm listened to more now than I ever have been there..

And I also have [my side business][], which is doing quite well. I changed a few things there, too -- I now have clients on support contracts, have sub-contracted work to others, and worked with some [great][] [people][] [as well.][] From the beginning, SquarePeg Systems has been a "let's see if this works" and, despite it's humble beginnings, it has.

As a family, we poked the box a lot. We were finally able to adopt Tyler after living with us for almost two years. The biggest changes this year has been starting (and all but finishing) a remodeling project in our living room (OK, headed up by Gina -- she has the vision for these kind of projects. I don't.) and switching to [Coram Deo Church][]. The church decision was hard -- we loved the people at Prairie Lane, but we wanted to be challenged in a different way. And God led us to Corem and we have been blessed (and challenged) by it ever since.

There are lots more signals I got about trying, and failing, and keep trying over the year. I could go on and on. But I'd rather poke the box then keep talking about it.

Review Pangolin Laptop From System76

| Comments

I had known that my early-model MacBook Pro was getting to the end of it's usefulness for me. I mean, it still runs but as software has grown more and more complicated, my MBP wasn't cutting it anymore.

Most people would just by another MacBook Pro! And, while that sounded tempting, I had a few things that held me back from that. For one thing, $2500 was a steep price for me and [my rising side-business.][] And the tools I use 85% of the time were not Mac specific. They are things like zsh, Emacs, Python, PHP, and some of[JetBrain's products.][] All of them would work on Linux, which is a much lower cost to entry than another Mac.

I started this journey around six months ago when I started scouring the Internet on what the best Linux-based laptop would be. I was quickly led to [System76][], a maker of Ubuntu-powered laptops, desktops, and servers. I was impressed when I scoured the web about this company. There were a lot of reviews and comments from their users and no one ever had anything bad to say about them. I mean, they had things that they wished that maybe were different, but everyone was happy with the hardware they were getting, how well it worked with the Ubuntu, and, more importantly, how happy they were with the post-sales support they were getting. The price was higher, especially compared to the laptops you get at big-box stores, but you got a machine that you knew would work with Ubuntu, and not have to fiddle around with it. But, regardless, it was certainly cheaper than a MacBook Pro!

aging MacBook Pro But I couldn't! I already had it maxed out at 2GB! So this was when I decided to make the plunge.

System76 has a wide range of laptops available, but the choice was easy for me -- [The Pangolin Performance.][] It seemed like a good development machine and my display needs are not that heavy to warrant the next step up. I spec'ed out what I wanted, and then compared it with a MacBook Pro. Yep, about half the price even though I was getting 6GB of RAM instead of Apple's 4GB, and I was getting a slightly larger hard drive. I thought I was getting a very good deal.

I ordered it about 10 days before Christmas, and System76 responded that it would ship within 8 business days. I was surprised when I found out that it was delivered early, and expected to arrive on the Tuesday before Christmas! And I was even more surprised to have it arrive a day earlier. Huzzah!

The packaging of the laptop was nothing to write home about, but it was extremely well cushioned and supported inside. It would be hard to damage it's contents. I took it out of the box and immediately started using it while the battery was charging

The first thing I noticed is how quiet it is. I didn't think the fan was even running! But it turned out that it was -- it's just that quiet. I had my Pangolin on my lap, doing lots of installation, configuring, etc., when my wife asked me if my lap was hot yet. I hadn't even thought about that, so of course it wasn't hot at all! I discovered why when I was packing it up after using it for a while on a table. Just left of where it was sitting on the table was a little hot, but underneath was fairly cool. It seems that the fan blows the heat straight to the left side instead of blowing it underneath. This allows the heat to escape and make your lap cooler as well as the underside of laptop itself. +1 for great design!

As for as Ubuntu? Almost flawless. I thought I had to call support to get Bluetooth working, but then I found the button to turn on the F12 key. That could have been an embarrassing phone call.

Note the word "almost" -- the one thing that I can't seem to get working right is to get Flash to use HDMI Audio. The HDMI Video works fine, and I got HDMI Audio to work out of normal Gnome apps, but Flash seems to cheerfully ignore the HDMI output and always goes to my speakers. Since my primary use of a developer machine and not a multimedia server, this is not a big deal.

The overall performance, however, is fantastic. The laptop boots in seconds, and every app I run starts in milliseconds. And I run Apache, PHP, MySQL and PostgreSQL most of the time. It finds my Android phone, Kindle, and iPod when I plugin them in and offers to start the right app.

So, after few weeks of fairly heavy use, would I recommend this laptop? Resoundingly yes! Especially if you are a developer in the open source space and just want everything to "just work". Everything just works for me -- without paying the Apple premium.