Skip to content

Instantly share code, notes, and snippets.

View kapso's full-sized avatar

Kapil kapso

View GitHub Profile
@kapso
kapso / Instrument Anything in Rails 3.md
Created June 20, 2012 19:52 — forked from mnutt/Instrument Anything in Rails 3.md
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)

class CreateFriends < ActiveRecord::Migration
def option_1
create_table :friends do |t|
t.string :user_guid, null: false
t.string :friend_guid, null: false
t.boolean :reciprocal, default: false
t.string :name, null: false
end
begin
# some code here that generates an exception, this code is my model class
logger.info "Some error..."
rescue => e
logger.error "Some error - #{e.message}"
Airbrake.notify e
end
@kapso
kapso / dabblet.css
Created December 22, 2011 09:41 — forked from fatgy/dabblet.css
Logo of some exhibition http://goo.gl/EK4Yp
/* Logo of some exhibition http://goo.gl/EK4Yp
from https://www.facebook.com/iCAREClub?ref=ts
*/
body {
font-size: 16px;
background-color: #DFE0E2;
color: #BA9254;
}
@kapso
kapso / dabblet.css
Created December 21, 2011 20:47
CSS3 Border-Radius with Border - Circle Avatars
/**
* CSS3 Border-Radius with Border - Circle Avatars
*/
/* General Styles */
body { background: url(http://subtlepatterns.com/patterns/white_texture.png);
font: 100 14px sans-serif;
color: #444555; text-shadow: 0 2px white;
text-align: center;
@kapso
kapso / move_to_rds.rb
Created October 4, 2011 05:48 — forked from guenter/move_to_rds.rb
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'