// Richard Hart / Hates_

Archive
computing

Ship It!

computing

“Any fool with a text editor can write code, but only an amazing few can code and make good choices around trade-offs. That’s the most valuable skill a developer can possess: the ability to make hard decisions.” – Ship It!

Shipping is hard. Perhaps even the hardest part when it comes to writing software. Opening yourself to real criticism is the most frightening and liberating thing you can do.

Read More

OSX Copy/Paste in tmux

computing

One of the big things that took me a while to get right in tmux was copy/pasting. The gripes of trying to get it to work were enough to nearly make me forget using it all together.

Here’s what you need to know.

Install reattach-to-user-namespace

brew install reattach-to-user-namespace

and then in your .tmux.conf

set-option -g default-command "reattach-to-user-namespace -l zsh"

Assign a binding to copy the current buffer

In your .tmux.conf set a binding to copy the buffer

bind-key C-c run-shell "tmux save-buffer - | reattach-to-user-namespace pbcopy"

Now it actually took me ages to work out how to use this properly. Once you have created the buffer, either through selecting it with the mouse or by using PREFIX – [ and SPACE/ENTER, press PREFIX – C-c and it will be copied to your system clipboard.

Use the option key

If you hold down the option key while in the terminal, you can create a selection just as if you’re weren’t in tmux.

Read More

Switching to tmux

computing, programming

Not being one to jump on bandwagons, I just had to try tmux after hearing so many people talk about it. tmux is a terminal multiplexer allowing you to run a number of terminals within a single screen as well as allowing you to detach and reattach to the same session as you please.

So what? I can just run multiple tabs and get the same effect!

Yes and no. I had been running multiple tabs, with vim in one window, a console session in another and tailing output in another, but the real revelation with tmux came when I tried out the tmuxinator gem. tmuxinator allows you to easily manage tmux sessions. With a simple yaml file you can create and start a tmux session with your editor, console and logging all setup, laid out and ready to go. This is incredibly useful with you work across multiple projects as quite frequently I would find myself in tab hell when having to switch from one project to another. Once you get past having more than four or five tabs open it become increasingly difficult to know which is which. tmux sessions mean I can keep everything related to a single “context” within one terminal session.

Getting up and running wasn’t 100% smooth sailing. Brian P. Hogan’s tmux: Productive Mouse-Free Development was invaluable. Even with less than a full days use, I’m pretty comfortable and have gotten over the initial slowdown that comes with switching to a new tool.

The only thing I miss is that I can no-longer use CMD-S for saving like in MacVim, but to be honest that’s a bad habit I need to break, as well as colour schemes aren’t quite as pretty in command line Vim compared to MacVim.

A few gotchas I encountered:

  • When using Vim and the Command-T plugin, up/down arrows wont work for selecting a file to open, you will have to use CTRL-J/K to move up and down and CTRL-C to close the pane.
  • When adding reattach-to-user-namespace to enable copy/paste to your tmux.conf, you must kill your tmux session for the change to take place, it’s not enough to just quit and restart tmux.
  • If you’re using rvm, opening a new pane/window into a directory with an .rvmrc wont properly load in the selected ruby. If you’re on bash then adding “cmd .” to your .bashrc should work (I haven’t tried it), but for me I had to add “source .rvmrc” to my .zshrc for it load in properly.
Read More

A day with Ubuntu Oneiric Ocelot (11.10)

computing

Omgubuntu

I just started a short term contract doing some RoR and was given a PC to work with. While developing on RoR on Windows is possible, it’s not what I’m used to or best at. As there were no Macs I could use, I thought I would give Linux a go. Seeing as I use Vim as my editor of choice, switching over should have been relatively painless.

I’ll just get to the point, that for many years now I’ve always said that I don’t think Linux as a desktop OS really cuts it compared to Windows or OSX, and having used it for a day and a half I still think that’s true. Off the bat the install seemed plagued with things I just wouldn’t expect from a “modern” OS.

The first major blunder came during the installation process. I booted off the CD and was told that a hard drive with Windows had been detected and would I like to install Ubuntu along side it. I chose yes and was shown a screen with a dropdown with HDs and a slider to allow you to resize the partition of the drive. I split it in half and set it going. Then only when half way through did I actually look at what drive had been selected by default, it had chosen an external drive as the one to get to work on. I totally accept that I should have checked it first, but I don’t understand why I was asked if I wanted to install it beside Windows for it to then choose a drive that Windows wasn’t even on as the one to set as the selected on.

The pain didn’t end there. Once finally up and running, my dual monitor setup was being mirrored which was easily remedied in the display settings control panel, but then it was apparent hardware acceleration wasn’t working. You couldn’t move windows without them struggling to keep up with the pointer. Trying to enable the proprietary ATI drivers didn’t work. Do I chose the normal or the post-release drivers offered? The normal drivers installed, but the displays would only mirror each other and the post-release ones wouldn’t even install. So I took a chance with some commands I found on a wiki which involved stripping away all the default ATI stuff and compiling my own drivers from scratch, which eventually got it running with hardware acceleration and with both screens working independently. I had no idea what the collection of commands I had run did to the system, which left me with the un-nerving feeling that the system was sort of hanging together by a thread. I was too scared to restart incase it came back with no display at all.

A few people advised me to ditch the Unity manager in favour of Gnome Shell, but that just made life even worse. I couldn’t even move windows without them crawling across the screen. It just felt like a total disaster and I had absolutely no faith in the install at all.

I remember in 1998 hearing about Linux Mandrake and traveling all the way to some dodgy warehouse in North London to buy a copy. My experience back then was actually a good one. Everything worked as it should of and using it day to day was fine. I don’t remember having any display or driver problems. It was only gaming that made me return to Windows back then. What has actually been achieved in 14 years? Some transparent UI elements? To me Linux still seems plagued by constant lack of driver support. Perhaps someone can explain even why just browsing the net on Linux looks bad? Why are no good fonts distributed? If you know exactly what you’re doing then you can make do. Plenty get by, perhaps I just don’t have the patience for it.

I just want something that works, and after some begging I convinced the place I’m at to let me use a Mac. Setting up took a fraction of the time, admittedly I’m used to it so it’ll be quicker to get up and running, but I didn’t have to worry about any drivers, display issues or whether or not my machine would survive a reboot.

Read More

Accessing values in your plist file from your iPhone/iPad app

computing, programming

Recently I’ve been coding some iPhone and iPad apps with multiple targets, all sharing the same codebase. Previously I had been using Preprocessor Macros to get the job done, but that soon turns messy and hard to maintain. I’ve since moved to just storing target specific values in each apps related plist file. Retrieving a value is as simple as:


 NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
 NSString *someString = [infoDict objectForKey:@"SomeKey"];
Read More