Optimistic locking in mongomapper and eventbus

Published: Apr 27, 2015 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

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

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: db.iphone_distributions.remove({}) db.devices.mapReduce( function() { var iosVersion = this.system_version.substring(10, 11); emit(this.model + iosVersion, { count: 1 }); }, function(key, values) { var count = 0; values.forEach(function(v) { count += v['count'];; }); return { count: count }; }, { query: {}, out: "iphone_distributions" } ) The first function is the map function, where I extract the model (iPad, iPhone or iPod) and concat the major version number. The emit function is a MongoDb function, where the first argument is an id, which groups the values, and the second argument is the stuff you want to work on in the reduce function. ...

October 31, 2014 · 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

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

Update all records in mongodb

Published: May 15, 2014 Recently we discovered a problem in [Be My Eyes](http://bemyeyes.org) 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

Trying Out Ruby on Rails on Windows Vista

Trying Out Ruby on Rails on Windows Vista Published: Nov 14, 2008 Source: https://khebbie.dk/trying-out-ruby-on-rails-on-windows-vista/ OK, so I am not excactly an early adopter, but I had some time and had to try it out. First I followed this guide: http://wiki.rubyonrails.org/rails/pages/RailsOnWindows Then I tryed out the first chapter of “Rails for .Net developers” from pragmaticprogrammers. I must say that it really just works! Of course this is a really simple app, but scaffolding is a great thing for CRUD.

November 14, 2008 · Klaus Hebsgaard

Trying Out Ruby on Rails on Windows Vista

Published: Nov 14, 2008 OK, so I am not excactly an early adopter, but I had some time and had to try it out. First I followed this guide: http://wiki.rubyonrails.org/rails/pages/RailsOnWindows Then I tryed out the first chapter of “Rails for .Net developers” from pragmaticprogrammers. I must say that it really just works! Of course this is a really simple app, but scaffolding is a great thing for CRUD.

November 14, 2008 · Klaus Hebsgaard

About Ruby

Published: Sep 23, 2008 Since there has been so much hype about ruby, I thought I’d better take a look at it. I must say it looks really good. There’s two things i like about Ruby: Duck-typing So many times I have been trying to make generic functionality for classes I didn’t own. So in C# I have no chance of implementing a common interface. ...

September 23, 2008 · Klaus Hebsgaard

About Ruby

About Ruby Published: Sep 23, 2008 Source: https://khebbie.dk/about-ruby/ Since there has been so much hype about ruby, I thought I’d better take a look at it. I must say it looks really good. There’s two things i like about Ruby: Duck-typing So many times I have been trying to make generic functionality for classes I didn’t own. So in C# I have no chance of implementing a common interface. With Duck-typing that is now possible, since I find that common functionality and do Duck-typing. ...

September 23, 2008 · Klaus Hebsgaard