www.archive-dk-2013.com » DK » N » NERDD

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".

    Archived pages: 11 . Archive date: 2013-08.

  • Title: Nerdd.dk
    Descriptive info: .. Nerdd.. Rasmus Bang Grouleff.. rasmus@nerdd.. dk.. I'm a developer, rubyist and js hacker.. I build stuff mostly for the web in Ruby and JavaScript.. Bubbles, capture, and all that jazz.. Jan 24, 2013.. A short tale of cron, rbenv and $PATH.. Dec 01, 2012.. Dogme running.. Feb 15,  ...   Code retreat in Aarhus?.. Oct 17, 2011.. The last chapter in The Saga of The Mem Leak.. Jul 09, 2011.. Return of the mem leak.. Jul 05, 2011.. YAML.. load considered harmful.. Jul 04, 2011.. Internet Explorer and CSS.. Jun 29, 2011.. Cuba.. rb demo app.. Mar 23, 2011..

    Original link path: /
    Open archive

  • Title: Bubbles, capture, and all that jazz — Nerdd.dk
    Descriptive info: Tweet.. DOM events aren t the funniest things in the World, but they re rather handy, and (at least if you ask me) the handling of them is pretty well thought out and gives a nice flexibility.. I have, however, run into a little interesting gotcha.. When you register two different event listeners on a DOM element, one for the capturing phase and one for the bubbling phase, and you trigger an event with the element as it s target, the order in which the listeners are registered matters.. My expectation was that the capturing event listener is always triggered first  ...   and Mozilla Firefox the registration order matters.. I have created a very.. simple example on jsFiddle.. , that enables you to test it in your browser.. Just click in each of the two boxes.. My result in both Chrome and Firefox is, as you can see.. Unexpected!.. Whether this is intentional, incidental or just a result of a poor specification, I am not entirely sure of.. It seems to me, though, that the.. DOM Level 3 Events specification.. defines the capturing phase to always precede the bubbling phase no matter where it happens in the DOM tree.. Follow me on.. Twitter..

    Original link path: /posts/bubbles_n_capturing
    Open archive

  • Title: A short tale of cron, rbenv and $PATH — Nerdd.dk
    Descriptive info: Ever tried to use rbenv within a cronjob?.. I have, and it was a bit of a struggle to get it up and running.. First of all cronjobs are not run in a login shell, and what that means is that your normal.. $HOME/.. profile.. etc.. startup scripts aren t executed.. So the first thing to do is starting a login shell that can run your job.. This is done with.. bash -l.. Now you of course need to execute your job, so it has to be a non-interactive shell.. Just do it like.. bash -lc job.. So far, so good.. This is similar to what you would  ...   t exist:.. env: bash: No such file or directory.. Which is strange, since it is no problem opening the login shell.. What is making the job blow up then?.. It happens to be the combination of.. $PATH.. and rbenv initialization, because of the call to.. rbenv init.. :.. eval $(rbenv init -).. This is looking for bash in the.. , and if bash is in.. /usr/local/bin.. , you re in troubles, since.. is quite restricted in cron - and therefore it doesn t include.. So you need to add it to.. before opening the login shell.. The complete command to execute the job then becomes.. PATH=$PATH:/usr/local/bin bash -lc job..

    Original link path: /posts/cron_rbenv_and_path
    Open archive

  • Title: Dogme running — Nerdd.dk
    Descriptive info: I m a geek and I actually quite like running.. But I really hate running around with all sorts of electronic gadgets to track the distance I m running, average speed, pulse and so on.. I feel that it is clutter and it draws unnecessary attention and when I m using this stuff, I m not enjoying the run as much as I could be.. That s why I don t use anything to record any data.. Since I.. am.. a geek, I love data - and I.. love.. charts with plots of data.. It makes my little geek heart go boom boom boom.. If only I could have a little electronic gadget, small enough to fit in a pocket, sturdy enough to withstand cold, heat, moisture and what else I might encounter during  ...   withstanding heat, cold, moisture, salt etc.. And make it small - I m thinking the size of the good old chip for Nike+ - it must be small enough to fit in a pocket for keys in running tights.. Equip the device with gps tracking, a timer and an altimeter, equip it with enough memory to be able to record 10 trips.. The data readout should be managed over bluetooth, and recharging the device should preferably be done wireless or through a small plug.. Oh yeah, the device should only have one button - start/stop recording! And some kind of indication of it s state.. I don t want any other kind of interaction with it than start , stop , dump data and charge.. If you make that, I ll use it! I promise!..

    Original link path: /posts/dogme_running
    Open archive

  • Title: This is why I love CoffeeScript — Nerdd.dk
    Descriptive info: This is why I love.. CoffeeScript.. not _.. all Elements.. stadiumSections(), (section) - section.. level() is 0.. Yes, it is valid CoffeeScript, and yet it is almost perfectly readable English (at least if you ignore the parentheses and other non-letter characters)..

    Original link path: /posts/loving_coffee_script
    Open archive

  • Title: Code retreat in Aarhus? — Nerdd.dk
    Descriptive info: I want to facilitate a.. code retreat.. in Aarhus, Denmark.. But I need some help with that.. I m needing the following:.. A date for the retreat (it could be cool doing it December 3rd as part of the.. Global Day of Coderetreat.. ).. A host with enough room to participants, electricity, internet, and a projector.. Someone to sponsor a nice lunch (and everything else needed to make it a nice day).. A co-facilitator.. A bunch of participants willing to geek out and learn something.. So, uhm.. Who re interested in helping me out?..

    Original link path: /posts/code-retreat-in-aarhus
    Open archive

  • Title: The last chapter in The Saga of The Mem Leak — Nerdd.dk
    Descriptive info: One last thing about.. the infamous mem leak.. This time with regard to Rails and testing.. As with any other gem used in a Rails app, it s sensible to declare the gem in the Gemfile.. That way you ll get the benefits of having Bundler to manage the gem.. But just adding.. gem psych.. to the Gemfile makes running tests blow up the same way as.. running the app with  ...   s a mem leak or not.. Tests probably don t execute in long running processes, so the memory should be freed regularly, when the processes terminate.. The easiest solution is to only include the Psych gem in the.. development.. and.. production.. groups in the Gemfile:.. gem.. '.. psych.. , groups: [.. :development.. :production.. ].. That way running tests will use Psych v1.. 0.. 0 that is bundled in MRI 1.. 9.. 2..

    Original link path: /posts/the_last_chapter_in_the_saga_of_the_mem_leak
    Open archive

  • Title: Return of the mem leak — Nerdd.dk
    Descriptive info: Having written only in.. general terms about how to fix the memory leak in Psych.. yesterday, I ll go into a little bit more detail today.. See in Rails it really isn t all that simple to fix it.. The most obvious way to start is to add.. to the Gemfile.. But Bundler itself requires Psych and YAML.. So when the Rails boot cycle gets to executing the Gemfile, it will already be too late.. Instead it s necessary to insert.. into one of the files that gets required before Bundler is required.. It could be.. config.. ru.. config/application.. rb.. config/environment.. or.. config/boot.. - either one of them will do.. That s easy enough to figure out.. The real catch.. If you re using.. Phusion Passenger.. for your Rails app, the solution above will unfortunately make your app blow up when trying to dump YAML.. The reason is that psych somehow gets required before the.. gets run.. Psych will because of this be in an inconsistent state.. When starting Passenger and requesting the first page, you ll get the following two lines in your log:.. /Users/rasmus/.. rvm/gems/ruby-1.. 2-p180/gems/psych-1.. 0/lib/psych.. rb:93: warning: already initialized constant VERSION /Users/rasmus/.. rb:96: warning: already initialized constant LIBYAML_VERSION.. And when trying to dump some yaml, this is what you ll see:.. ArgumentError: wrong number of arguments (2 for 1) from /Users/rasmus/.. rvm/rubies/ruby-1.. 2-p180/lib/ruby/1.. 1/psych/nodes/node.. rb:33:in `to_yaml from /Users/rasmus/.. rb:190:in  ...   Bundler.. setup twice is.. # harmless.. If this isn't the correct thing to do after all then.. # there's always the load_path_setup_file option and.. # setup_load_paths.. require.. rubygems.. bundler.. Bundler.. setup.. end.. Now how do I get around this? Don t bother looking in the documentation for Passenger - it doesn t say anything about this.. But fortunately there is plenty of comments in the stills.. rb file.. Just scroll a bit further up.. There are 3 solutions:.. bundle/environment.. config/setup_load_paths.. or a file pointed to in an option called.. load_path_setup_file.. However how this option is passed to the.. prepare_app_process.. method isn t documented and I haven t digged around in the Passenger code long enough to know this.. The solution I like the best is anyways using the.. file - this can be added to version control instead of using some Bundler dependent file and some configuration option.. If you have added.. to one of the files loaded in the Rails boot cycle, you don t have to put anything in the.. file.. It just has to be present to stop Passenger from requiring Bundler.. Ps.. : Phusion, why is.. et al an undocumented feature?! I can t be the only one who s needed to be able to control what is loaded before Passenger starts loading Rails app stuff?.. Update.. : I ve also written about.. what to do when running tests..

    Original link path: /posts/return_of_the_mem_leak
    Open archive

  • Title: YAML.load considered harmful — Nerdd.dk
    Descriptive info: The title is very much a rip-off from the famous letter by.. Edsger Dijkstra.. titled.. Go To Statement Considered Harmful.. Actually YAML.. load is not all that harmful.. The problem is that version 1.. 0 of.. (psych is the default engine for parsing and emitting YAML in MRI 1.. 2) is part of MRI 1.. 2 and psych 1.. 0 has a memory leak somewhere in the parser.. What this means is that everytime YAML.. load is called, more and more memory is leaked.. Normally this isn t too big a problem - we don t load that much YAML and we don t do it too often.. And when we re talking webhosting where worker processes are shut down regularly, we usually don t get hit severely enough by the memory leak to notice it..  ...   Patterson.. (who I have the utmost respect for!) has released psych as a gem and it s been patched.. But it s not as simple as just grabbing the gem and require it - trying to require psych will just load the 1.. 0 version.. What is needed is a bit of Rubygems magic (seriously - I have no idea what happens).. After installing the gem, this is what it takes to use psych 1.. 0 for YAML parsing:.. Psych.. ::.. VERSION.. =.. 1.. And with this, you re ready to run processes that load a shitload of YAML without worrying it will gobble up the memory (at least because of a memory leak).. : I ve written a bit about.. how to use the Psych gem in Phusion Passenger.. what to do when testing Rails apps..

    Original link path: /posts/YAML-load-considered-harmful
    Open archive

  • Title: Internet Explorer and CSS — Nerdd.dk
    Descriptive info: Internet Explorer.. never.. ceases to amaze me - so many quirks and so much strange behavior.. The latest discovery is that it not only imposes a limit on how many stylesheets it loads.. It also impose a limit on the size of the stylesheets.. If you have more than 32 stylesheet elements in a page, IE only loads the first 32.. That s fairly easy to discover by.. searching on Google.. But the size limit on each stylesheet isn  ...   plenty big for most websites (anyone remember the Bill Gates quote about 640 kB?).. But nevertheless does it happen - at least have I had practical experience with this limit today.. It was quite a surprise, and I almost couldn t find any description of this limit (please, Microsoft, document caveats, limits etc.. in your software).. But not anymore - now there s an entire blog post dedicated to the size limit!.. And the magic size was 348 kB!..

    Original link path: /posts/ie-and-css
    Open archive

  • Title: Cuba.rb demo app — Nerdd.dk
    Descriptive info: Last week I spoke about the Ruby micro webframework.. at the latest meeting in.. Aarhus Ruby Brigade.. , and during that talk I built a.. very simple todo list application.. using Cuba (obviously) and CouchDB.. It is really simple and as demo apps usually are, this one is definitely not suitable for much else than serving as an  ...   play with it.. It s by the way not compatible with Ruby 1.. 8.. To get it running just do the following:.. install CouchDB and fire it up.. create a todo database.. clone the repo.. run.. bundle install.. rackup.. and point your browser to http://localhost:9292.. Should you have any comments or suggestions, please let me know on Twitter!..

    Original link path: /posts/cuba_rb_demo_app
    Open archive


  • Archived pages: 11