Skip to content

Instantly share code, notes, and snippets.

View roidrage's full-sized avatar
🌱
Planting seeds

Mathias Meyer roidrage

🌱
Planting seeds
View GitHub Profile
@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)

@jeffrafter
jeffrafter / server.js
Created August 28, 2010 21:37
Twitter OAuth with node-oauth for node.js+express
var express = require('express');
var sys = require('sys');
var oauth = require('oauth');
var app = express.createServer();
var _twitterConsumerKey = "YOURTWITTERCONSUMERKEY";
var _twitterConsumerSecret = "YOURTWITTERCONSUMERSECRET";
function consumer() {
Object.extend(Date.prototype, {
strftime: function(format) {
var day = this.getDay(), month = this.getMonth();
var hours = this.getHours(), minutes = this.getMinutes();
return format.gsub(/\%([aAbBcdDHiImMpSwyY])/, function(part) {
switch(part[1]) {
case 'a': return $w("Sun Mon Tue Wed Thu Fri Sat")[day]; break;
case 'A': return $w("Sunday Monday Tuesday Wednesday Thursday Friday Saturday")[day]; break;
case 'b': return $w("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec")[month]; break;
%s/\C\<g:NeoComplCache_EnableAtStartup\>/g:neocomplcache_enable_at_startup/ge
%s/\C\<g:NeoComplCache_MaxList\>/g:neocomplcache_max_list/ge
%s/\C\<g:NeoComplCache_MaxKeywordWidth\>/g:neocomplcache_max_keyword_width/ge
%s/\C\<g:NeoComplCache_MaxFilenameWidth\>/g:neocomplcache_max_filename_width/ge
%s/\C\<g:NeoComplCache_KeywordCompletionStartLength\>/g:neocomplcache_auto_completion_start_length/ge
%s/\C\<g:NeoComplCache_ManualCompletionStartLength\>/g:neocomplcache_manual_completion_start_length/ge
%s/\C\<g:NeoComplCache_MinKeywordLength\>/g:neocomplcache_min_keyword_length/ge
%s/\C\<g:NeoComplCache_MinSyntaxLength\>/g:neocomplcache_min_syntax_length/ge
%s/\C\<g:NeoComplCache_IgnoreCase\>/g:neocomplcache_enable_ignore_case/ge
%s/\C\<g:NeoComplCache_SmartCase\>/g:neocomplcache_enable_smart_case/ge
@tmm1
tmm1 / em-rpc-server.rb
Created April 16, 2009 21:49
simple EM rpc server
require 'rubygems'
require 'eventmachine'
require 'socket'
module RPCServer
include EM::P::ObjectProtocol
def post_init
@obj = Hash.new
end
def receive_object method