David's Dingen

Mijn webloghonk

DJMonitor Is Born

In my work I have an Rails application wich uses Delayed Job to do some work, like exporting PDF files. We ran in to some trouble with the jobs wich caused them to stall. Then I began searching for some kind of monitoring for the Delayed Job worker, I found some very usefull thing to see if the Delayed Jobs were running… This was not the problem I was facing though, I was having trouble with jobs that couldn’t upload files for example. So the Delayed Job worker process was running, it was just not doing anything usefull.

So that I searched further, and found delayed_job-monitor by Michael Guterl on Github. The gem he wrote is a good starting point for me. But I wanted to be able to add an config file. I also didn’t like the name and the way it connected into Delayed::Job. That last bit is a matter of opion. I decided to create a own gem, and so DJMonitor was born. This gem in core is a ripped version of the delayed_job-monitor gem. Wich in base is very nice.

DJMonitor works like this:

  1. gem install dj-monitor –pre
  2. cd to the rails app (cd /var/rails_apps/delay/current)
  3. create a dj-monitor.yml file! This bit is important fow now (else I get spammed)
  4. run dj-monitor

The dj-monitor.yml file is meant for configuring the gem. Here you can (and must) set options for DJMonitor to send the right mails. A example dj-monitor.yml file looks like this:

yaml dj-monitor.yml
1
2
3
  alert_to: 'some1@example.net,person2@company.nu'
  alert_from: 'monitor-dj@davidakachaos.nl'
  alert_subject: 'OMG! DJ has a problem here!'

When setup right, the gem will mail you a summery overview when things go bad. I have set this gem up as a crontask. Be sure to use the full path to the dj-monitor command (whereis dj-monitor) else cron might be confused what you mean.

If you have any issues (bare in mind that this gem is a beta release, things can go wrong!) please report them to me!

Thanks for reading!

My Baby Girl Turned Two

Yesterday my babygirl turned two! She is getting big! Sure we are proud of here, and she really does make our live worth living. For that we are parents, right; being proud of our daughter.

We have had a great day of all family and friends visiting, bit to busy for her though. Our baby was completely worn out at the end of the day and fell asleep like a brick ;-)

Nieuw Blog

Het was tijd om om te schakelen naar een nieuw soort blog. Daarom ook dat ik gekozen heb om het radicaal aan te pakken.

Een nieuw blog en een nieuw thema, zelf een geheel eigen wijze om dit blog te maken. Zonder in te veel details te treden, dat doe ik een ander blog, wil ik zeggen dat ik nu Jeckll met Octopress gebruik om dit blog te maken. Dat betekend onder andere dat dit hele blog geen database meer nodig heeft. Alles is statisch. Daar zal met name mijn webhost blij mee zijn. Het betekend ook dat ik alles nu zelf in een Ruby manier kan maken.

In de aankomende tijd zal ik ook vaker dingen gaan posten in dit blog. Meer dan ik gedaan heb de afgelopen tijd. Ik ben erg druk geweest met van alles en nog wat. Dus ik hoop dat ik wat meer tijd krijg/heb voor dit blog.

Wel moet ik even zeggen dat ik ook meteen mijn blog heb opgeschoond. Dus alle artikelen van meer dan een jaar geleden zijn bij deze verdwenen. Misschien dat ik ze (op verzoek) terug haal, maar niet zomaar.

In ieder geval wens ik jullie veel lees plezier.

Attribute Defaults for Rails 3.0 and 3.1

Today I was having some time on my hands, and started searching the Ruby community for some useful things. I found Attribute Defaults (github) by Dimitrij Denissenko. This gem is for Ruby on Rails 3.0.x and 3.1.x for now, so if you are still on Rails2.x you’re out of luck. This very useful gem lets you setup defaults for Active Records with ease. No more def initialize or def set_defaults! I like Dimitrij’s solution above others because it follows the Rails principle of attr_protected and the likes. Here a quote from the Github README:

First, a simple case …

class Foo < ActiveRecord::Base
  attr_default :age, 18
  attr_default :last_seen do
    Time.now
  end
end
Foo.new # => age: 18, last_seen: '2010-09-15 10:30'

… or the same via mass-definition …

class Foo < ActiveRecord::Base
  attr_defaults :age => 18, :last_seen => lambda { Time.now }
end
Foo.new # => age: 18, last_seen: '2010-09-15 10:30'

So, as you can see, it’s a simple line of attr_defaults to define the default value of a field. More complex things can be done, be sure to read all about it in the README.

Excuses

I'm sorry comic In 1 woord; geniaal…. Ik denk dat ik dit ook maar eens doe. Zeker bij mensen die het inderdaad steeds opvatten dat ik sorry zeg omdat ik er wat aan kan doen. Natuurlijk kan ik er (vaak) niets aan doen. Het is gewoon zaak dat je sorry zegt om je medeleven te tonen. Kijk er is ook een verschil met mensen die het steeds zeggen. De zinnen als; ‘Ik begrijp dat het vervelend is.’ of ‘Ik zou me ook niet vrolijk voelen als het mij gebeurde’ dat zijn dood doeners. Wel is het zo dat deze zinnen meestal gebruikt worden bij Call-Centers of instancies. En dan is het extra vervelend, want deze mensen kunnen er wel wat aan doen… Maar goed. Ik denk dat ik bovenstaande comic maar eens in het echt moet doen. Zeker omdat de reacties dan natuurlijk hilarisch worden!

Guild Wars 2 — Game of the Year 2012?

I really hope they release Guild Wars 2 soon. I mean, we have been teased by trailers as this: Guild Wars 2
logo And now I really want to play! I know, I can go to a convention or such to play the demo. But I think this game \ will blow away other games such as Word of Warcraft (World of Walking). When they release this game, I will try to take some time off ;-) And when Guild Wars 2 is finally released, my guess is Q1 2012, it will storm the charts and make Game of the Year with ease…

Dit Speelgoed Moet Je Echt Kopen!

Ik bedoel hoe cool is het dat je kind Engels leert en meteen ook goed leert wat de meeste mensen in het Engels doen; vloeken!