Skip to content


My new funky editor. A story about Sublime Text 2

A prologue

Today, I use Sublime Text 2 for just about all my text editing needs. It is fast and fairly stable. It is customizable and it can use plugins from Textmate. It also allows me to have split windows and its concept for finding files, methods, and editor actions make me a productive developer.

Over the years, I’ve used a myriad of text editors. Most of my time has been spent in Vim. My fingers are so used to Vim’s modal editing, I tend to expect the world to move up or down when I press j or k. Every time I’ve tried out new editors, I’ve always missed h/j/k/l. Sublime Text 2′s Vintage editing mode satisfies most of my modal editing needs. All the important commands are there, and new ones are added as users request them.

One big issue I’ve had with editors that can be extended by code, is that the language used for extension isn’t very friendly. I’m not well versed in Lisp, but I can get around. Emac’s ability to be customized is unsurpassed, but personally I don’t feel that I need a complex environment with an editor as a bonus. Most times I just want to create text. On the other hand, Emac’s Org Mode is unsurpassed, so I do find myself wishing that it existed in other places with the same amount of functionality as the the original.

Vim’s vimscript is more than functional. It can be used to create some truly useful plugins. Tim Pope has proven this time and time again. The problem with vimscript is that is really only useful inside of vim. Vim also allows you to extend it using other languages, such as Python and Ruby, but I haven’t explored either of those enough to comment on them.

I tried Sublime Text 2 as a diversion from my normal editor, MacVim. I’d been hearing many things about it, so I wanted to try it out. It passed the 5 minute red face test with ease, so I decided to use it exclusively for a two week period. That was over a month ago, and now I’ve purchased it as well.

Why have I stayed in Sublime Text 2 for so long?

The obvious first response to this question is because it isn’t bad on the eyes. I like soft pastel colors on a dark background, and I wasn’t disappointed with what I saw.

Sublime Text 2's pretty colors

I learned a long time ago that the keyboard is the fastest way to navigate, so I require my editing environment to be fully driven by the keyboard. Finding files is as simple as pressing ⌘P (I use a Mac) and typing a combination of the path and the file name. The interface is fuzzy, so you don’t need to type all the characters to find things in a hurry.

Find files quickly!

There are also ways to find methods/functions in your current file and run commands quickly as well.

Command and Goto Symbol

You didn’t have to read this blog post to see those in action. You could have went to Sublime Text’s home page to see them detailed. I want to share why I’m not moving away from this editor in the foreseeable future.

As I said before, I don’t like to use the mouse. I avoid it to the point of shedding a single silent tear every time I have to use it. Keyboard navigation in ST2 (as I will refer to it from now on) is more than sufficient. You can create files and move between buffers with keystrokes. I can even bring up a Quake style console to see editor output, and show off my elite Python skills if I need to.

ST2's console

As we all know, all problems in computer science have already been solved. (At least that’s what I like to think) Sometimes we need to look to past to solve the problems in front of us. Looking to the past, we find Textmate’s snippet and theming system. Instead of creating yet a new format, ST2 allows you to import Textmate bundles. Problem solved.

You’d be mistaken if you thought that ST2 was just a new skinned Textmate, however. ST2 brings its own configuration to the table as well. It isn’t strictly a Mac style preference dialog, but it’s JSON back configuration is pretty easy to learn.

ST2's preference dialog

ST2′s plugins are all written in Python. Python isn’t too hard to learn if you programmed in any other C style language, and there are already plenty of plugin samples to base your new code off of. The plugins have access to basics, like your where your caret is, what lines you have highlighted, and the details about the current files. Plenty of people have written plugins to extend ST2 to their liking.

I’m currently following the Dev releases of ST2. What this means that I get new and fixed editor functionality a couple times of week. In the past month of using ST2, I’ve seen improvements to editor stability and new features. It’s like Christmas for my editor twice a week.

I’m sure at this point (if they’ve made it this far), that all the emacs and vim people are shaking their heads. Those editors do all this and more. If you are shaking your head, you are missing the point. There is plenty of room for improvement and usability. ST2 is just another attempt at finding that sweet spot. Usage of any editor is not an admission of disdain for any other environment. My vim code folding screencast is still the most popular post on this site. I’m happy to have found something to give me the energy to write blog posts again.

So, now I’ve been using this editor for a while now, and now it is time to make it mine. Stay tuned for part two of this series where I share how I’ve molded the editor to match my coding style.

Posted in Smarticus Says.


Why people don’t ask for advice

I’ve been writing code in some form or another for over 20 years now. In that time, I’ve explored quite a few different languages and problem domains. The great thing about software development, is that there are more problems to solve than any developer or set of hundreds of developers could solve.

Lately, I’ve been exploring a new problem domain. I want to write a graphics rendering engine. It has nothing to do with the web, so it is new territory for me. I’ve been researching question and answer sites, reading books, and writing lots of exploratory code, trying to immerse myself into this new (new to me that is) technology.

Last night, I happened upon a person who is employed by a prominent company, who is paid to do what I’m trying to learn. I don’t get many chances to ask questions to real life gaming people, so I decided to seize the chance. I started off slowly trying to explain what I was trying to learn, the approach I was taking, and what some of my long term goals were. I hope my face didn’t show it at the time, but I was horrified at the response; I was told that I was wasting my time.

No one wants to waste time. Life is finite. Time is a premium resource for someone who works to put food on the table and spend time with their family. So then I had a decision to make: would I take the advice at face value, or would I dig to understand why the advice was given. I kept digging.

The new problem domain I’m working with is based heavily on math. I wasn’t good at math in high school (maybe I just wasn’t good at school), so many of the concepts I’m learning about now are new to me. The advice giver told me no one uses that math. I then asked him how else would he be able transform objects on the screen. He replied that there are libraries to do that. I also wondered about the best method for composing screen graphs. He replied that there were libraries that did that as well. I finally followed up with specific questions about various kind of optimizations, and he told me, that with my level of knowledge and choice of implementation technologies, that I would never run into those problems. The conversation went on, but it wasn’t progressing on any level.

Suddenly, I was questioning my choice of continuing to write the engine. Why would I want to do something that eventually end up being a failure? Why would I want to waste my time? At that point I realized something. I’m not trying to emulate the person giving me advice. I am forging my own path. I thought I was asking for advice, but instead I was giving this guy a chance to steer me wrong.

Why don’t people ask for advice? In most cases, the advice given will not be any good. People generally won’t give you advice that will enable you to be better than them or even as good as them. They’ll just give you a summary of their understanding that will likely enable you to get to one step below their level at best. Maybe at some basic level, we are a selfish species.

What will you do the next time someone asks you advice?

Posted in Smarticus Says.


If your tests don’t scale, you might want to look in the mirror

“Our test suite is slow”
“Our test suite is fragile”

You have to approach your test suite the same way you approach your application. In many cases, people don’t pay enough attention to your test suites. There are only a few guidelines to follow to have sane test suites that run in a decent amount of time.

  1. Be careful what you mock. Mocks are deposits on future pain. Sure they speed up execution, but they aren’t resilient to changes you’ve made in other sections of your code.
  2. Don’t talk to external services unless you absolutely need to.
  3. I bet the box you run your tests on uses multiple cores. Why not introduce a test runner that can actually take advantage of it.
  4. Only create just enough setup to actually test your behavior.
  5. Be observant of side effects. If you are using something like factory girl, models will be created and run callbacks. Is that really important to what you are testing?

There are techniques you can try that will allow you to reduce test times significantly. Don’t let your previous failures or perceived inabilities trick you into thinking it isn’t possible. Testing most definitely scales. I guarantee it!

If all else fails, just drop me a line. I’m sure I can help steer you in a better direction.

Posted in Smarticus Says.

Tagged with .


Fake camera for smoke testing Android application

While building out my current Android project, I came across the need for a way to have a camera on the emulator that didn’t require any manual input. Since I’m using Robotium to do my smoke testing, I headed to their mailing list first. After a couple of minutes of searching, I found the solution to my problem, so I decided to bundle it up for other developers to use as well. I’d like to thank Marcus Chen for the original idea.

To use this camera, all you have to do is select it during your smoke test run. I’d also suggest that you make it the default.

Currently, the camera only circulates through three images. It is possible to swap them out or add more if you fork the FakeCamera project at Github.

If you are curious what test driven development looks like in Android, I’ve created a sample app screencast that walks you through the basics. (looks great in HD)

 

If there is interest, I will definitely spend more time in creating a suite of Android development screencasts. I even tossed around the idea of monetizing these as well if folks are looking for higher quality or deeper dives into Android development.

Posted in Smarticus Says.

Tagged with , , .


I’m at Madison Ruby

I go to a lot of conferences. Not many have started with great improv sessions that concluded with custom handshakes. You missed out if you didn’t come to Madison Ruby this year. I’m really looking forward to the next two days.

Posted in Out and About.


Pet Peeve Thursday: ruby private statements

Indenting private methods in Ruby grinds my gears. I’m sure people do for the assumed aesthetic value, but it really is unnecessary. Instead of indenting your private methods, think about the abstractions you are hiding, and create a new class!

Posted in yerdoinitwrong.


Introduction to vim text objects

It has been way too long, since I’ve shared a video on vim. Today I want to introduce vim text objects to those of you who might be unfamiliar. Text objects provide an extremely easy way to interact with text using motion commands.

Posted in Geek Vids.

Tagged with .


Locking Mac OS X using Applescript

I don’t believe OS X comes with a menu item to lock the screen. You can cheat by configuring a password on the screen saver, but there is an easier way. Open up the Applescript Editor and paste this code:

You can then use this as a Launchbar Action. I believe Alfred has this functionality already built in. This is posted here, so I’ll never have to look it up again.

Posted in Smarticus Says.


Why do we still question why we write tests?

I enjoy reading blog comments. In most cases, I enjoy it more than the actual blog article itself. I also really enjoy blog posts about improving process and becoming more productive.

Often, I’ll read a article about testing, and will casually skip over comments about “Why should I TDD? There is no evidence that it actually does something?”. I also skip comments with name calling and the like. Unfortunately, there is one type of comment that I can’t skip over: If you question why we are testing, then we (as developers) have failed.

This one comment in particular went something like, “when things change and propagate up the code base, doesn’t having unit tests mean twice the work?”. I only have one answer for a question like that. YES! It does mean twice the work. The alternative is worse. The alternative is not know how much work will be needed. The best case scenario that I can think of would put it some higher multiple than two.

This is just something to think about the next time you think that skipping that one small unit test.

Posted in Smarticus Says.

Tagged with .


The myth of Ruby’s beauty

Almost every morning when I’m going through my huge collection of RSS feeds, I see a blog post that mentions the beauty of Ruby the language. For years, I’ve dismissed it as weird thing to say. This morning, while reading my RSS feeds, the unavoidable post pops up that mentions Ruby’s beauty, and I think I’ve hit some sort of breaking point.

I’m not a professional on any matters of human psychology, but I know that people prefer things that are beautiful to things that aren’t. At a basic level, I can see why it makes sense; things that are nice to look at are nicer than things that aren’t.

A large part of week is spent writing code of some sort. I write front-end and back-end code. I’ve been dabbling in mobile code as well. As I’m developing my code, I don’t get any sense of beauty from it. Sometimes I’m proud of the conciseness, or the utility of things I’ve written, but I don’t get any pleasure that I can associate with beauty.

While writing this, my friend Bill Mill stopped by to say hello, and he thinks the opposite: there is beauty to be found in well written code. Some languages are more appealing to others because their constructs and idioms make them a greater pleasure to work with. I can see that point, but I still won’t call any code beautiful. This is the best parts of opinions. You can have differing opinions, but respect that their life situations have led them down a different path.

Now, I want to move on what really prompted this post. Seeking beauty in languages might be just one part of a bigger thing. For years, I’ve been working on a hypothesis about “smart people”. For this conversation we will just say that “smart people” are thought workers. As a smart person, you produce intangibles through code, design or something else.

I want to call my hypothesis, “Bubble Theory”. As a disclaimer, I’m quite sure this isn’t a new thought. I’m sure there are tomes of thought on this particular subject. So my Bubble Theory is that smart people enclose themselves in a bubble. This bubble surrounds the person and everything they do. This bubble is physical, but also exists on a psychological level.

http://www.flickr.com/photos/zzubnik/460488845/

I’m sure each and every one of you have seen a smart person in their bubble. Up to and including high school, the bubble expanded as far as it could, and everything inside of the bubble was the smart person’s domain. Smart people are the smartest thing inside of their bubble.

At the college level, the bubble might have found its first bruises. Novice smart people bubbles bump hard against other bubbles. Some bubbles shrink at the expense of others which grow even greater. This is where we first feel the effects of the bubble, but don’t quite recognize what is going on.

After we graduate to the real world, bubbles become interesting. Many smart people know that they are smart. They believe that they can learn anything given enough time and enough study. This might be true. I certainly believe it. We sometimes wield our bubbles naively by assuming that because we think we are smart, others must think as well.

Smart people have to be the smartest person in their bubble, so what happens when another bubbles presses up against it? Or worse tries to smash it in oblivion? In some cases the bubble retracts, but this isn’t true in every case. In some cases, the bubble aggressively tries to expand on its own. This friction point between bubbles is where workplace unrest comes from it. It is where the nasty areas of Ruby vs Python or Java vs C# exist. People don’t like having their bubbles shrunk. It is akin to physical assault in some circles.

There is a secret about bubbles that many smart people don’t care or want to learn. We can make our bubbles permeable. Multiple bubbles can exist in one space. There is room for multiple competing opinions. All it takes to make your bubble permeable is an open mind. You have to understand that ideas and opinions don’t simply exist. They are constantly built using experience and are molded using new experiences constantly. You have to understand you might not like the idea of someone else’s bubble, but you’ll accept it, because you respect it. With enough work, you might be able to absorb other bubbles into your own.

So what can we learn from this? Every where we go there will be smart people. They are shaped by their experiences, and you are shaped by yours. Are your smarts greater than their smarts? Who knows? You’ll have to work on finding that out by yourself. When you do find out, work on working with others rather than trying to be greater. If your bubble is greater, it’ll grow because you’ve accumulated new bubbles rather than bursting them.

Posted in Smarticus Says.

Tagged with .