EventBus in a Sinatra app

Published: Oct 27, 2014 I had a sinatra app (the Be My Eyes app), that I thought had a bit too much code in the route file. So I investigated how to make that better. What I came up with was that it would be great to have some kind of EventBus, where I could send events out and respond in a very decoupled manner. It would be nice to be able to run the event handlers asynchronous, but that was not a hard requiriment from the beginning. I searched on github and came up with event_bus by Kevin Rutherford. I asked on the lrug mail-list about peoples experience with event_bus. Not a lot of people had tried it out, be at least one person could recommend Kevins work, so I took the plunge and installed the gem. (Furthermore an I could see that a “sister” gem exists that will handle events in sidekick, so the asynchronous part got a checkmark as well) ...

October 27, 2014 · Klaus Hebsgaard

Frontend developers and their tools

Published: Jun 23, 2014 I read some frontend developer magazines like net magazine and Web Designer Magazine. Now I really like both of them, and so I thought about how great it would be to have something like that for backend developers (or maybe full stack developers). And I thought about why it is that no such magazine exist. Then it struck me how seperated the backend developers are vs the frontend developers. I have seen many frontend developers who jumped from python to .net to ruby or whatever. On the other hand I don’t see many backend developers jump around like that. A backend developer would be considered as a “.Net developer” or a “Ruby on Rails developer”. ...

June 23, 2014 · Klaus Hebsgaard

Git bisect

Published: May 31, 2014 Oh how I love git bisect In the last couple of weeks I had some bugs that were introduced at a unknown commit. Actually I couldn’t even find out what code was working wrong. I did however know excactly what was wrong in the UI. For problems like this git bisect is perfect. What git bisect does is it helps you do a binary search in the commits and find the buggy commit. ...

May 31, 2014 · Klaus Hebsgaard

My Mac Setup

Published: May 19, 2014 This is just a run through of my Mac setup - I do this mostly for myself, so I can find it whenever I need to setup a Mac, but you are welcome to take a peek :)- First of all Caps Lock (I never hit Caps Lock except by mistake): PC Keyboard Hack is an excellent tool for mapping your Caps Lock key. Funny enough in the settings of OS X, you cannot map Caps Lock to Esc, so you need an external tool for this. ...

May 19, 2014 · Klaus Hebsgaard

Update all records in mongodb

Published: May 15, 2014 Recently we discovered a problem in Be My Eyes where an id was not unique. So we needed a quick fix to make all ids a forthrunning unique number before solving the problem in the code. On stackoverflow i found this question: http://stackoverflow.com/questions/4146452/mongodb-what-is-the-fastest-way-to-update-all-records-in-a-collection And I modified the code to work for our schema. Please note: the code in the question was working, but slow for many millions records (a problem we don’t have yet ;-). ...

May 15, 2014 · Klaus Hebsgaard

Heroku like deployment for your cloud host / VPS

Published: May 12, 2014 For Be My Eyes I have set up a heroku like deployment environment Basically I followed this approach: https://www.digitalocean.com/community/articles/how-to-set-up-automatic-deployment-with-git-with-a-vps But there is one problem with the above approach, and that is that I want to be able to push other branches than master to the server. Thats how I push to QA and staging. A gooogle search found this for me: https://coderwall.com/p/oj5smw ...

May 12, 2014 · Klaus Hebsgaard

Practices of a proffesional developer

Published: Apr 12, 2014 Over the years I have picked up a list of practices that I think are essential to a professional developer - these are of course my opinions - other may disagree. We don’t expect our customers or managers to ask for these things - but rather as professionals we do this because - well we are professionals. When estimating a task at hand we don’t add “unit testing” tasks ‘cause these are just things we do Just like at doctor does not expect his patients to ask him to wash his hands - neither do we expect customers or managers to ask us to do unit testing etc. Big books are written about each of theªse subjects, hence I don’t go into much detail about each - I just list them. Either research on the internet or find a good book if you don’t understand an item. I am mostly a web developer, so these practices apply to that space - but most also apply to other spaces. ...

April 12, 2014 · Klaus Hebsgaard

Start umbraco with mvc four

Published: Feb 12, 2014 I found an article by Ben Morris and it was very useful, however it seems to be gone now, so to remember it, I keep it here: The below text is from this stackoverflow This setup worked really well for me (Umbraco version 6.1.6) Firstly, start an empty MVC 4 project in Visual Studio – make sure it is an empty project as you will not need any of the baggage that comes with other project templates. Add the NuGet Umbraco Cms Core Binaries package which will manage the various dependencies and references that Umbraco 6 requires for you. Copy all the files from the Umbraco installation ZIP archive directly into your project in Visual Studio except the App_Code and Bin folders – you won’t need the binaries as they are managed by NuGet and the App_Code folder is not used in a web application project. If you want Umbraco to play nice to MVC and be able to use Razor views, you should change the default rendering engine to MVC in Config\UmbracoSettings.config like so: ...

February 12, 2014 · Klaus Hebsgaard

Hvorfor jeg koder

Published: Jan 27, 2014 Hvorfor er det fedt at kode? Bemærk: En redigeret version ligger op klean.dk: Det er godt engang i mellem og tænke over det man gør og hvorfor man gør det. Derfor vil jeg hér reflekterer lidt over hvad jeg laver og hvorfor mit arbejde er det bedste i verden. Jeg har flere gange overvejet om jeg skulle skifte branche, men er hver gang nået frem til at svaret er “Nej!” ...

January 27, 2014 · Klaus Hebsgaard

Euler in f#

Euler in f# Published: May 12, 2013 Source: https://khebbie.dk/euler-in-f/ Here is my solution to Euler problem 2 in F# I took the memoization code from Wiki Books Yeah I know I should use infinite lists - but have not come around to it yet let memoize f = let dict = new System.Collections.Generic.Dictionary<_,_>() fun n -> match dict.TryGetValue(n) with | (true, v) -> v | _ -> let temp = f(n) dict.Add(n, temp) temp let rec fib = memoize(fun n -> match n with | 1 | 2 -> 1 | _ -> fib (n-2) + fib(n-1)) let evenNumbers x = x % 2 = 0 let belowBelow4millions x = x < 4000000 [1..50] |> List.map fib |> List.filter belowBelow4millions |> List.filter evenNumbers |> List.sum |> Dump

May 12, 2013 · Klaus Hebsgaard