TILs (Today I Learneds)

TILs (Today I Learneds) Published: Sep 6, 2016 Source: https://khebbie.dk/tils-today-i-learneds/ I have started a TIL. To be quite honest, I don’t post a lot on this blog, but on my TIL, I do post a lot more often.

September 6, 2016 · Klaus Hebsgaard

Values in software development

Values in software development Published: Sep 6, 2016 Source: https://khebbie.dk/values-in-software-development/ During my job as a software developer I have stumbled upon some values that makes a lot of sense to me: We value code that is easy to maintain over code that is easy to write I am not sure if this is the origin of this value, but I first heard of this value in the book Growing Object Oriented Software, Guided by tests. This should be the overarching value of 99% of all software developers. You will have to go over your code again and again, and so will your co-workers or someone coming after you. So the few minutes or hours you save now is just like wetting your pants, you will feel the warm now, but it gets a lot colder in time ;-) ...

September 6, 2016 · Klaus Hebsgaard

Vlog: what is an API (for non-tech people)

Vlog: what is an API (for non-tech people) Published: Sep 16, 2015 Source: https://khebbie.dk/vlog-what-is-an-api-for-non-tech-people/ So I decided to try something new: I made a video explaining what an API is! Of course if you are a software developer you probably already know, so move on then, or wait just a second - you could show this video to a business person you know :-) So if you are, say maybe a business person, you have maybe heard developers talk about the API, and maybe you thought: “What the heck is an API?”. Well that is what I am going to explain to you in this video: ...

September 16, 2015 · Klaus Hebsgaard

Mix tasks in Phoenix using Ecto

Mix tasks in Phoenix using Ecto Published: Aug 16, 2015 Source: https://khebbie.dk/mix-tasks-in-phoenix/ Working with Phoenix version 0.16 I needed to import some records from a csv file. My first problem was where to place the tasks, after some research I found that you place them under lib/tasks and name them some_name.ex (not exs) The code for the task should look something like: You can now run the task with the command mix task_name That was the first problem. ...

August 16, 2015 · Klaus Hebsgaard

Optimistic locking in mongomapper and eventbus

Optimistic locking in mongomapper and eventbus Published: Apr 27, 2015 Source: https://khebbie.dk/optimistic-locking-in-mongomapper-and-eventbus/ In Be My Eyes we use mongomapper and eventbus, both are very good tools that make my everyday life as a developer easier - except when it doesn’t. We had a problem where more than one helper is added to a call. This should not happen. We have a pretty simple if statement in our code. The thing is that many helpers were allowed through the if statement down to the “default” case, where only one should be allowed. I really lost a lot of hair trying to figure out why more than one helper could fall through. It really made no sense, since we assigned a helper and assigned answered to be true. This should mean that the next time a helper tries to answer, she would be told that the call was already answered. But in many cases this did not happen. I searched the codebase through and through for many hours with two things in mind that could be wrong: ...

April 27, 2015 · Klaus Hebsgaard

Setup resque mailer on Ubuntu 14.04

Setup resque mailer on Ubuntu 14.04 Published: Feb 7, 2015 Source: https://khebbie.dk/setup-resque-mailer-on-ubuntu-14-04/ I recently moved a site from EngineYard to Digital Ocean. The site used resque mailer to send emails. So I had to set up resque to handle the queue. I decided to start it with upstart and added the following script to /etc/init/resque.conf description "Resque worker configuration" start on runlevel [2345] stop on shutdown respawn respawn limit 5 20 script echo resque Job ran at `date` >> /var/log/resquejob.log cd /path/to/rails_app && bundle exec rake resque:work QUEUE='*' RAILS_ENV=production end script I can now control the script with ...

February 7, 2015 · Klaus Hebsgaard

So you think the internet is a dark and hostile place...

So you think the internet is a dark and hostile place… Published: Jan 19, 2015 Source: https://khebbie.dk/so-you-think-the-internet-is-a-dark-and-hostile-place/ Well think again! Last night we had a big breakdown on bemyeyes.org. Some famous actor mentioned us on facebook - which is by the way great, and well the database could not handle it. Within 6 minutes the database went from responding within about 3-600 ms to 6-8000 ms. I dived into the problem and it made no sense to me since I didn’t deploy anything new. But it was clear that the database was being slow. I used google and could find no sense of it all. I thought with the publicity Be My Eyes has had in the last days, and it being a non-profit org that maybe someone would help out on the internets :-) ...

January 19, 2015 · Klaus Hebsgaard

Working from home

Working from home Published: Jan 16, 2015 Source: https://khebbie.dk/working-from-home/ So yesterday we did the big launch of Be My Eyes, and what a splash we made! I am so proud of having been part of this. I work from home, which basically means that I have set up an office in the bedroom. Working from home is amazing: If you have to pick up the kids or run an errand you just do it, and catch up on the hours later. ...

January 16, 2015 · Klaus Hebsgaard

Map Reduce in MongoDb

Published: Oct 31, 2014 I had a problem where I needed to aggregate some documents in MongoDb. In Be My Eyes, we keep records of which version of ios the app is installed on. We do this to know which versions to support. The natural solution would be to use the aggregation framework, however I had to do some string manipulation, since we only care about major versions at the moment. So I went ahead and learned me som map - reduce. Map - reduce is a pretty simple concept, where you in the map step extract some data, and in the reduce step do some kind of manipulation of that data, to get some kind of values out of it. The code I endend up with was: ...

October 31, 2014 · Klaus Hebsgaard

Unix commandline

Published: Oct 29, 2014 Just a few scripts useful for changing many files at once. To replace all double quoted strings with single quoted strings in ruby to make rubocop happy: find . -type f -iname '*.rb' -exec sed -i.bak "s/\"/'/" "{}" +; Now find all the places where you do string interpolation and make them back to double quoted strings. Then to remove all .bak files when you are sure you got it right" ...

October 29, 2014 · Klaus Hebsgaard