Skip to content

Instantly share code, notes, and snippets.

require 'resque/errors'
class DatabaseBackupJob
def self.perform(id, foo, bar)
# do backup work
rescue Resque::TermException
# write failure to database
# re-enqueue the job so the job won't be lost when scaling down.
Resque.enqueue(DatabaseBackupJob, id, foo, bar)
@doitian
doitian / specs.js.coffee
Created March 12, 2012 19:33
3 ways to test ajax requests or other asynchronouse lib based on jquery deferred
# The second way is recommended, which is flexible, and also work for non jQuery ajax library.
# Setup sinon sandbox
beforeEach ->
@sinon = sinon.sandbox.create()
afterEach ->
@sinon.restore()
@desandro
desandro / requestanimationframe.js
Created February 19, 2012 23:29 — forked from paulirish/rAF.js
requestAnimationFrame polyfill
/**
* requestAnimationFrame polyfill by Erik Möller & Paul Irish et. al.
* https://gist.github.com/1866474
*
* http://paulirish.com/2011/requestanimationframe-for-smart-animating/
* http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
**/
/*jshint asi: false, browser: true, curly: true, eqeqeq: true, forin: false, newcap: true, noempty: true, strict: true, undef: true */
@dux
dux / db-pull
Created November 13, 2011 00:04
MYSQL database pull from remote server (heroku like)
#!/bin/bash
FILE="/var/www/${1}.sql"
echo "Delete remote dump [${FILE}]"
ssh root@178.79.163.176 "rm -rf ${FILE}"
echo "Remote database dump"
ssh root@178.79.163.176 "mysqldump --user=root --password=XYZ ${1} > ${FILE}"
@jokull
jokull / index.html
Created September 3, 2011 20:00
CoffeeScript Backbone Tumblr with JSONP
<html>
<head>
<script type="text/template" id="tpl-tumblr-post">
<% if(title){ %>
<h2 class="title">
<a href="<%= post_url %>"><%= title %></a>
</h2>
<% } %>
<%= body %>
<?php
/**
* Custom configuration bootstrap file for ExpressionEngine
*
* Place config.php in your site root
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/config.php
* Add require(realpath(dirname(__FILE__) . '/../../config_bootstrap.php')); to the bottom of system/expressionengine/config/database.php
* If you have moved your site root you'll need to update the require_once path
*