Ok so today I ran in to a small hickup when rounding numbers in Ruby.
I had a number, a float to be precise. The number was 42.300000000000004
When I asked the number in Ruby which class it was, it responded to me as Float:
42.300000000000004.class# => Float
But when I then started to round the number; to my supprise it said
This might seem a bit silly. But I guess it has something to do with that Ruby floating points have fixed precision. So my numbers are out-of-range so to speak. So when I convert the calls to go through BigDecimal (because it has arbitrary precision) this problem is gone… Of course there is the trade-off that BigDecimal costs more memory for this.
I really like doing OpenSource development. Not only because it give me exposure as a developer, but also because I can solve my own problems. By this I mean that when I find a problem in a project, I can fix it! We all know this, but I really want to show how much we can help each other out.
Just recently I got myself involved, more actively as before, in the workless gem. I blogged about this gem before so I won’t repeat myself about the workings of the gem. But I noticed how I enjoy to help people with issues with the gem. I have a app installed on my iPhone so I can easely browse the issues, and as I watch the repo I get notified when new issues are reported. When I can, I try to help out and fix the problem. When the maintainer of the repo approves of the pull request, I’m really satisfied with my work.
To see the project move forwared, partly because of my help, that’s a real cheer-me-up for me. I hope to help more people and projects out in the future when I get a chance and when time permits.
So if you know of a project, or if you have a project, on wich you cloud use a extra set of eyes or some help… Please drop me a line!
Ruby on Rails has some security issues as of late. So we need to update the Rails version on our projects.
If you have a few, that gets old fast if you do it by hand… So I figured I can create a Thor task for this.
Now this approch works nicely for subfolders and detecting the Gemfiles, replacing the old Rails versions with the new ones.
Adding the changes to Git. Right now I’m still working on the script and have a few issues, the main one being RVM rc files that need to be respected when updating the Gemfile. This issue can be resolved, but I’m not sure how right now.
I’m continueing to search the web, and to see if someone can give me a solution or a pointer in the right direction.
Today I was very glad to see that lostboy has accepted the pull request of jaimeiniesta and myself on the workless gem. He also release the changes as version 1.1.0!
It’s my first real try to help a Open Source project, and to see the changes being put in the gem that fast (after the original pull request was open for about 3 months) I was really excited!
Workless is an addon for delayed_job (> 2.0.0) It is designed to be used when you’re using Heroku as a host and have the need to do background work with delayed job but you don’t want to leave the workers running all the time as it costs money.
In this new version, this adds support for scaling using multiple workers. Many thanks to jaimeiniesta for add the multiple workers, I just updated the gem to use the new and improved heroku_api gem.
I hope this new version makes your scaling needs for Heroku a bit better and nicer.
I started using CloudFlare on my site. I ran into CloudFlare when I was googling some stuff, and found a website that was down. CloudFlare made sure the site was still reachable when it was down. I went and looked into it, it turned out CloudFlare was more than just a safeguard for when a site goed down. It also makes sure that a site performs really fast and easy. And for a static site as this one, it’s really simple to setup.
Mind you; it does require some technical know-how… When you use the service, no need to adjust the nameservers of your domain. CloudFlare uses this to setup the caching and other services for you.
Up to now I really like the service they provide, it’s fast and easy to setup and really has a speed performance when setup that way.
I recommend you check them out for your own website and/or blog. They can be found at the CloudFlare website. I hope this service will help you speed your website and/or blog :-)
As I wrote earlier, I like to listen to music when I’m working. Now I heard on some podcast I listen to that they listen to smooth music, or even some heavy metal… As they can’t understand the lyrics..
Now, I’ve a very differtent kind of music to listen to… Like this one:
Sure, it’s a bit hard music choise… But this is just the music I like to listen to… What do you like to listen to while working (programming or something else)??
Sometimes I really love to play music very loud. Boost the Volume to 45 or higher in my car, or annoy my neightbours with very loud music. I’ve the luck to live in a neigthberhood where it’s accepted to play loud music sometimes. I have a daughter aged two, so I don’t do it when she is sleeping, nor when she is standing right there. But when I’m home alone, or in my car… Well, just say that I want to feel music sometimes instead of just hearing it.
Yes, I am aware that it hurt my health… Yes I can annoy people with it… Sometimes… I don’t really care about that.
And really, it’s not just hardcore (BOOM BOOM BOOM Music as my parrents an some friends call it) that I play loud. Some music is just beatifull to play really loud. Some dutch artists like ‘Van Dik Hout’, ‘Acda en de Munnik’ and so on can really be played loud! And what to think of playing ‘Edith Piaf’ or ‘Jacques Brel’ at volume max? Shivers down my spine sometimes…
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:
gem install dj-monitor –pre
cd to the rails app (cd /var/rails_apps/delay/current)
create a dj-monitor.yml file! This bit is important fow now (else I get spammed)
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:
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.
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.