Richard Hart

Something @ Somewhere • Kent, UK

Richard

  • Whether your starting a new project, company, job etc, you all too easily get caught up in the initial whirlwind of getting things off the ground. It’s exciting creating that new empty git repository, making your first few initial commits and hobbling together the start of what you imagine to be the next startup success story. Then a few weeks in that excitement fades and you’re faced with an ever-increasing mountain of tedious and boring things that need to be done. The project soon becomes boring and the temptation to jump ship and work on the next exciting idea rears its head like an itch that screams to be scratched.

    No one will ever tell you that 90% of the work that you’ll need to put in will be boring. That you’ll have to grind out immensely boring things to move towards your goal of completing your project. That’s why so many startups fall by the way-side. That’s why there are so many projects on Github that once showed immense promise, but now just sit abandoned as a sea of issues and pull-requests mount up.

    The ones who make it aren’t the ones that are doing the exciting work, it’s the ones that can face up to the challenge of seeing things through until the end.

    Your project’s most boring work, will sometimes turn out to be your project’s most important work.

  • It was the one year anniversary of my DAS recently and I thought I should write a bit about what it’s been like riding a motorbike ever since. I’ve done pretty much exactly 5,000 miles on the Yamaha XJ6. Though wind, rain and snow I’ve ridden it, and truth be told I’ve loved nearly every second of it.

    I’ve always been huge into cars. I spent untold thousands on my old 200SX making it a mean beast of a car, but riding a bike has really changed my perspective of them. I still love cars, but have a different appreciation for them now. Even on my bike with it’s measly 75BHP, open the throttle wide and it’s the most incredible sensation of speed that no car (that I’ve driven at least) can compare to. Experiencing that has shifted my perspective of cars to being less about raw speed to being more about what they are and stand for.

    Thankfully I have had no accidents. The closest being a woman who pulled out and just clipped my leg and the other being when I stalled moving out of a parking bay and dropping it. I’m not ATGATT, but I wear a helmet 100% time; jacket, boots and gloves 99% of the time, but normally just jeans. If I know I’ll be on the motorway or fast moving roads I’ll kit up in the leg department.

    Running costs have been pretty good. I manage about 110 miles out of a full tank. This time last year filling up cost around £15, but now seems to be more around £20. Tax is around £30 for six months. It just had its annual service which turned out to be more expensive then I anticipated as it needed new tyres. The final bill was £550 (£250 for tyres and £150 labour). In the last year I’ve also had heated grips and a tail tidy fitted which has added a bit to the total cost. A big expense has also been gear. You need gear for winter and gear for summer. You can skimp, but how good will cheap stuff perform when it comes to protecting you?

    The majority of my miles have been in and around London. I haven’t gone out for a countryside blast as much I would have liked, mostly because there haven’t been any weekends nice enough to tempt me out. I’ve only done one really long motorway journey (up to Telford for i46) and that had to be the most mind numbing and boring experience ever, it didn’t help that it was freezing and raining too. Getting around London is great though, you can get pretty much anywhere in no time, without traffic and parking being an issue.

    Random thoughts: Heated grips are a must, it can get blisteringly cold. Riding in the rain is nowhere near as bad as you think it would be. 70mph is comfortable, 80mph is not, there is a huge difference between the two. You will come across idiots intent on killing you every day. Bikers love to aknowledge each other, it’s like being in an exclusive gang. Scooter riders are to be looked down upon. You will miss second gear plenty of times and will feel like a fool when you do. It’s extremely easy to break the speed limit. Bikes and shopping do not mix. Riding a bike instantly makes you a badass and a hit with the ladies.

  • If you follow the Devise Wiki on setting up Rspec and Devise you may end up wanting to set an expecatation on the currently signed in user.

    Don’t fall into the trap of setting it on the original user model as your specs will still fail:

    user.should_receive(:blah).once # Won't work

    Rather, you should set it on the controller’s current_user:

    subject.current_user.should_receive(:blah).once # Will work!

  • I don’t think in terms of “soon I’ll have this” or “soon I’ll have that.” I think in terms of “I got these points today, and I have these other points yet to win, before I go to sleep at the end of the day.” That’s all it takes to get things happening – Giles Bowkett – My Gamified Life

    An excellent way to think about The Daily Practice. I’ve been doing this for a while and it makes an immense difference. I started to drop the ball in July though and still haven’t got around to printing myself a new calendar for August. I’ll post up my previous two months at some point.

  • The only thing that I’ve ever done right in my life is to doggedly pursue the things that I’m interested in. To the detriment of everything else. No matter what anyone else says.

    Pursuing my interests regardless of what anyone says has worked well for me. I’m naturally interested in business. I’m naturally interested in coding and design. I’m naturally interested in writing.

    And so my goal is this: to be able to do those things sustainably, for the rest of my life.

    That, in a nutshell, is why I do this every day.

    I initially skipped over this post, but I’m glad I went back and read it. Exactly the sort of things that run through my mind. It’s so easy to get caught up in the startup frenzy, that if your product isn’t social, free, an app or whatever, that you’re doing it wrong. The startup way is a lottery. One where most players number one and only goal is to get funded, that somehow somehow once we do that, the rest will be easy.

    I just want to sell products to customers and make money that old fashioned way. It’s easy to forget that the number of businesses making money (and lots of it) day in day out far out weigh the number of businesses winning the startup game. We just don’t hear about them, because making money is out of fashion.

  • Scott Adams


    “Losers have goals. Winners have systems.” Scott Adams

  • 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.

  • 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.
  • One slightly annoying thing about Postgres over MySQL is that trying to reset a database with rake db:migrate:reset fails if there are connected clients and as I use Pow for development, killing the process doesn’t always free up the connections.

    To get around this you can quickly kill all connections with this command:

    
    ps x -o pid,command | grep postgres | grep my_database | cut -f 1 -d " " | xargs kill
    
  • SpotSnax


    I thought I’d have a look at the SpotifyAPI to see what it’s like. Pretty nice that everything is just HTML + JS. I knocked up a small app which simply provides search links for the currently playing track. It also changes as the player’s track changes.

    The source is on Github.

  • Strangely nginx does not support variable names with dashes or other characters other than lower/uppercase letters, digits or underscores. This means that if you are trying to log cookie values which contain dashes, as in my case, you can’t do it.

    Two workarounds are logging the all the cookies in one go, which can be overwhelming:

    
    log_format main '"cookies=$http_cookie;"';
    

    The other option is to map your cookie names to a variable that can be used by nginx:

    
    map $http_cookie $my_cookie {
      default '';
      ~Cookie-With-Dash=(?[^\;]+) $mc;
    }
    
    log_format main '"Cookie-With-Dash=$my_cookie;"';
    
  • …always optimise for personal growth, for building your “success pool” that you can leverage to go from smaller successes to bigger successes. Steer away from choices that reduce this personal asset.

    Excellent article on what it take to be successful. When we were working on our startups, we always shoot for the stars. Every bet was an all or nothing one, where revenue and profits were problems for the future. A lot of those decisions were out of our hands, while we always believed that first priority should always have been making enough money to keep our heads above water, rather than living on borrowed time.

  • “The problem, often not discovered until late in life, is that when you look for things in life like love, meaning, motivation, it implies they are sitting behind a tree or under a rock. The most successful people in life recognize, that in life they create their own love, they manufacture their own meaning, they generate their own motivation.” Neil deGrasse Tyson

  • I’ve been working on a templating engine recently and had the need to substitute some variables on the page with the result of an slightly expensive remote API call. The first iteration was just a simple replace on the page:

    
    render_placeholder result, 
        "some_page_var", 
        ApiWrapper.some_expensive_call
    
    def render_placeholder result, name, value
      result.gsub! name, value
    end
    

    This “worked” but the problem is the call would be made even if the variable that needed replacing wasn’t on the page. The easy fix is to check it exists before making the substitution:

    
    render_placeholder(result, 
      "some_page_var", 
       ApiWrapper.some_expensive_call) if has_placeholder?(result, "some_page_var")
    
    def has_placeholder? result, name
      !!result[name]
    end
    
    def render_placeholder result, name, value
      result.gsub! name, value
    end
    

    While this works, once you have a load of results you want to replace there ends up being a lot of duplication, and it’s easy to check the wrong variable compared to what you want to replace. One way to solve it is by passing the api call as a block to the substitution method. This way we can tidy up the code:

    
    render_placeholder(result, "some_page_var") { ApiWrapper.some_expensive_call }
    
    def has_placeholder? result, name
      !!result[name]
    end
    
    def render_placeholder result, name
      return "" unless has_placeholder?(result, name)
      result.gsub! name", yield
    end
    
  • 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.