Javascript closures as a way to retain state

              ·

Long time no blog! Let's get back into it with a nifty and clean way of retaining state in Javascript - closures. I was recently looking for an easy way to call a specific function after two separate/unrelated AJAX calls to two remote endpoints have been completed. The naive method would be to make the first AJAX call -> callback to the second AJAX call -> callback to doSomething, but we can use the fact that these two AJAX calls are not related and run them concurrently.


Bits of javascript goodness

             

(This blog post is better followed with the associated github repo. Run the Sinatra server with ‘ruby slowserver’, pop up a browser, and follow the revisions to see how the code gradually gets better. :) ) Recently at work, we wanted to modify some js ad code to include weather data for better ad targeting. For certain caching reasons, weather data has to be fetched by an AJAX call, then fed to the ad code.


Format perlcritic output as TAP to integrate with Jenkins

              · ·

Perl::Critic is a nifty syntax analyzer able to parse your Perl code, warn you against common mistakes and hint you towards best practices. It's available either as a Perl module or a standalone shell script (perlcritic). Unfortunately, there is no standard way to integrate it with Jenkins. Jenkins, the continuous-integration-tool-formerly-known-as-Hudson, is the cornerstone of our continuous building process at work. It checks out the latest build from Git, runs a bunch of tests (mainly Selenium, as we develop a website) and keeps track of what goes wrong and what goes right.


A gentle introduction to GNU screen

              ·

You probably heard of GNU screen. It's handy, ubiquitous, and dead simple. Here's how to use it! Open a terminal and type: screen You're welcomed by an introduction message, press enter, and… You're in a shell. Uh? Screen is simple screen is a terminal manager, so it's logical that the first thing you see when you start it is a terminal. This terminal is as vanilla as the terminal we started from.


Keep GimmeSomeTune running

        

As a follow-up on my previous post on the question, which advocated a simple (but bad) approach to keeping GimmeSomeTune running, here's a better way! The Good Thing (tm) to do is to use OS X's built-in mechanism to start and keep processes running, namely launchd. What we have to do is simply to write a plist containing the info needed by launchd, namely: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.


Optimising a video editor plugin

              ·

During the past few weeks, I have been writing a C++ plugin to grade C41 digital intermediates in Cinelerra, an open-source Linux video editor. C41 is the most common chemical process for negatives, resulting in films that look like this — you probably know it if you've ever shot film cameras. Of course, after scanning those negatives, you have to process (“grade”) them to turn them back to positive. And it's not as simple as merely inverting the values of each channel for each pixel; C41 has a very pronounced orange shift that you have to take into account.


Rails in a week - day 7

              ·

Today was the last day of my Rails week. I added some database-backing to my app (with a fully scaffolded model and all!) for the countries’ data and refactored a fair bit, though I'm still unsure about a few decisions I made, such as if I should put the base data in seeds.rb or in a migration. Oh, well. The website is available here: http://antipodes.plui.es And its source code is on GitHub.


Rails in a week - day 6

              ·

TL;DR: testing works, I learned i18n, and fixed a bug through TDD. After writing a simple little functional test and making it run through rake test, albeit slowly, I installed Spork and autotest. From what I gathered, Spork is an RSpec-only thing, so I wrote a few RSpec tests instead of functional tests. After a bit of tweaking, everything was going smoothly between Spork and autotest, all running RSpec, but my file in test/ was ignored.


Rails in a week - day 5

              ·

TL;DR: polishing. Trying to get into TDD, but slowness makes it a strange experience. This “day 5” has been more or less spread over two days because of other engagements (mowing the lawn and subscribing an insurance policy for abroad if you wish to know the details), and I didn't keep precise tracks of the steps I took. The major milestone is that the MVP for Antipodes is online at http://antipodes.


Rails in a week - day 4

              ·

TL;DR: it deploys! Finally! After a full day spend battling cryptic error messages, I finally got my 10-lines Rails app to deploy. First thing in the morning, I decided to switch to using rvm on my production machine too, in order to have the same setup and version on Ruby (1.9.2) for testing and production. This meant also reinstalling the important gems (bundler, rails, rake). The production machine uses nginx+Passenger, which I reinstalled (following instructions here) in order to work smoothly with this now rvm-ed ruby.