Skip to content

Instantly share code, notes, and snippets.

module Merb::Template
class << self
# overwrite the load_template_io to look in app/views/templates if the
# given path is not found
def load_template_io(path)
io = super
Merb.logger.debug "Merb's load_template_io(#{path}) => #{io.inspect}"
if io.nil?
if path =~ %r((.*/app/views/).*(/[^/]+)$)
template_path = $1 + 'templates' + $2
@fuba
fuba / download_ustream_live.pl
Created October 19, 2010 16:07
download live video from ustream using rtmpdump.
#!/usr/bin/perl
# this script is an implementation of http://textt.net/mapi/20101018201937
use strict;
use warnings;
use LWP::Simple;
my ($ustream_url, $file, $stop) = @ARGV;
@mathiasbynens
mathiasbynens / nytimes-option-a.user.js
Created March 22, 2011 09:12
Userscript to bypass the badly implemented paywall on nytimes.com. Use the “raw” links to install.
// ==UserScript==
// @name Bypass New York Times paywall (20 article limit)
// @author Mathias Bynens <http://mathiasbynens.be/>
// @link http://mths.be/axa
// @match http://www.nytimes.com/*
// ==/UserScript==
(function(d) {
d.getElementById('overlay').style.display = 'none';
d.getElementById('gatewayCreative').style.display = 'none';
@xaviershay
xaviershay / loader.rb
Created May 17, 2011 07:43
DataMapper hacks to generate raw SQL
# Yields the given models wrapped in Loader::Table objects that can be
# used to write SQL. The block should return an array with the SQL as
# the first element, and variable substitutions as the rest.
#
# Example
# using_sql(Article) {|a|
# ["SELECT #{a.*} FROM #{a} WHERE #{a.id} = ?", 1]
# }
def using_sql(*models)
opts = models.extract_options!
@sturadnidge
sturadnidge / tmux-1.8-on-CentOS-6.x.txt
Last active May 10, 2021 18:31
Install tmux 1.8 on CentOS 6.x minimal (64bit)
# download latest libevent2 and tmux sources, and extract them somewhere
# (thx bluejedi for tip on latest tmux URL)
#
# at the time of writing:
# https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
# http://sourceforge.net/projects/tmux/files/latest/download?source=files
#
# install deps
yum install gcc kernel-devel make ncurses-devel
@nrabinowitz
nrabinowitz / README.md
Created December 9, 2012 20:51
Raster geocoding with D3.js

This demonstrates raster-based reverse geocoding using canvas and D3.js. Geocoding is based on the color of the pixel at a given projected position. Note that the canvas is only shown here for the sake of explanation and debugging - this would in fact probably work faster if the canvas was not attached to the document at all.

The biggest remaining issue here is precision, which depends on:

  • the size of the canvas, and
  • the projection used.

Determining the optimum size based on the accuracy of your data is left as an exercise for the reader. Edge cases will also fail here, generally returning null - one option might be to stroke neighborhoods in a color, and then return an "uncertain" value for any non-grayscale pixel.

@algal
algal / nginx-cors.conf
Created April 29, 2013 10:52
nginx configuration for CORS (Cross-Origin Resource Sharing), with an origin whitelist, and HTTP Basic Access authentication allowed
#
# A CORS (Cross-Origin Resouce Sharing) config for nginx
#
# == Purpose
#
# This nginx configuration enables CORS requests in the following way:
# - enables CORS just for origins on a whitelist specified by a regular expression
# - CORS preflight request (OPTIONS) are responded immediately
# - Access-Control-Allow-Credentials=true for GET and POST requests
@raine
raine / html.vim
Created May 21, 2013 15:09
Make vim play nice with HTML templates inside script tags ~/.vim/after/syntax/html.vim
unlet b:current_syntax
syn include @HTML $VIMRUNTIME/syntax/html.vim
syn region htmlTemplate start=+<script [^>]*type *=[^>]*text/template[^>]*>+
\ end=+</script>+me=s-1 keepend
\ contains=@HTML,htmlScriptTag,@htmlPreproc
@6174
6174 / Random-string
Created July 23, 2013 13:36
Generate a random string in JavaScript In a short and fast way!
//http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
diff --git a/probes.d b/probes.d
index dd7a7bf..e077bd8 100644
--- a/probes.d
+++ b/probes.d
@@ -214,6 +214,16 @@ provider ruby {
Fired at the end of a sweep phase.
*/
probe gc__sweep__end();
+
+ /*