Skip to content

Instantly share code, notes, and snippets.

@julien-duponchelle
julien-duponchelle / semaphore.js
Created January 31, 2012 21:22 — forked from jayjanssen/semaphore.js
Node.js semaphores
var Semaphore = function(callback, context) {
this.semaphore = 0;
this.callback = callback;
this.context = context || this;
};
Semaphore.prototype.increment = function(i)
{
if (i == undefined) {
i = 1;
# inspired by http://ariejan.net/2010/08/23/resque-how-to-requeue-failed-jobs
# retry all failed Resque jobs except the ones that have already been retried
# This is, for instance, useful if you have already retried some jobs via the web interface.
Resque::Failure.count.times do |i|
Resque::Failure.requeue(i) unless Resque::Failure.all(i, 1)['retried_at'].present?
end
# retry all :)
Resque::Failure.count.times do |i|
@julien-duponchelle
julien-duponchelle / task.md
Last active October 21, 2022 14:32 — forked from dscottie/task.md
Coding Task

Coding Interview - The Task

You need to implement the following user story:

As a user, I want to see the trains that fit my travel schedule, So that I can decide what to buy

Steps