Skip to content

Instantly share code, notes, and snippets.

View plukevdh's full-sized avatar
🔥

Luke van der Hoeven plukevdh

🔥
View GitHub Profile
@lukeredpath
lukeredpath / Delayed::Job daemon script for delayed_job
Created January 29, 2009 19:13
An easy way to take the effort out of managing your background worker process is to write a simple wrapper script using the *daemons* gem.
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
daemon_options = {
:multiple => false,
:dir_mode => :normal,
:dir => File.join(dir, 'tmp', 'pids'),
:backtrace => true
@mnutt
mnutt / Instrument Anything in Rails 3.md
Created September 6, 2010 06:50
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@desandro
desandro / jquery.imagesloaded.js
Created January 26, 2011 18:01 — forked from paulirish/README.md
$.fn.imagesLoaded jQuery plugin
// $('img.photo',this).imagesLoaded(myFunction)
// execute a callback when all images have loaded.
// needed because .load() doesn't work on cached images
// Modified with a two-pass approach to changing image
// src. First, the proxy imagedata is set, which leads
// to the first callback being triggered, which resets
// imagedata to the original src, which fires the final,
// user defined callback.
@program247365
program247365 / gist:963273
Created May 9, 2011 20:08 — forked from briangershon/gist:832491
Integrating Git on Mac OSX with Microsoft TFS on Windows
@plukevdh
plukevdh / hold_music.rb
Created June 23, 2011 21:49
Replicating functionality of the hold music "twimlet" from Twilio (http://labs.twilio.com/twimlets/holdmusic)
require 'httparty'
require 'twilio'
module Twimlet
module HoldMusic
include HTTParty
AWS_URL = "s3.amazonaws.com"
def generate_playlist(bukkit='com.twilio.music.classical', options={})
@bucket = "http://#{bukkit}.#{AWS_URL}"
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@jbjornson
jbjornson / SwitchToFile.py
Last active October 29, 2015 19:45
Show a input panel to switch to a currently open file
import sublime_plugin
import os
# -------------------------------------------
# You will need to create a key mapping for this, something like:
# { "keys": ["alt+e"], "command": "switch_to_file" }
# -------------------------------------------
class SwitchToFileCommand(sublime_plugin.WindowCommand):
def run(self):
self.display_list = []
self.views = []
@sowawa
sowawa / sinachiku.rb
Created June 18, 2012 07:00 — forked from mattn/sinachiku.rb
sinatra on mruby
require 'HTTP'
require 'UV'
module Sinachiku
@routes = { 'GET' => [], 'POST' => [] }
def self.route(method, path, opts, &block)
@routes[method] << [path, opts, block]
end
def self.do(r)
@routes[r.method].each {|path|
@plukevdh
plukevdh / levenshtein.erl
Created November 7, 2012 03:13
Implementations of the levenshtein algorithm
-module(levenshtein).
-export([distance/2]).
first_letter_check(OneLetter, TwoLetter) ->
if OneLetter =:= TwoLetter -> 0
; true -> 1
end.
distance(String1, String1) -> 0;
distance(String, "") -> string:len(String);