Skip to content

Instantly share code, notes, and snippets.

View leandro's full-sized avatar
🏠
Working from home

Leandro Camargo leandro

🏠
Working from home
View GitHub Profile
dns - http://freedns.ws
google apps - http://google.com/a
yola, pra criar o site - http://www.yola.com/
logonerds, logos por $50 - http://www.logonerds.com/
wuffo, forms builder - http://wufoo.com/
analytics, pra monitorar - http://www.google.com/analytics/
blog (tumblr)
twitter
adwords
@leandro
leandro / mysql-index-analyzer.sh
Created November 23, 2009 10:26
USAGE: ./mysql-index-analyzer.sh YOUR_DATABASE
#!/bin/sh
#define you database user:
USR="root"
#define your database password:
PWD=""
formatt () {
LINES=$1
FLINE=$(echo "$LINES"|head -1)
# basic example on how to create module methods not accessible for classes are including it
module Foo
class << self
def show_me
puts 'Foo'
end
end
end
require 'rubygems'
require 'haml'
require 'effigy'
require 'effigy/core_ext/hash'
template = Haml::Engine.new(%{%html
%head
%title
%body
%h1
@leandro
leandro / gist:263095
Created December 24, 2009 09:07
ddiff: Improved diff for directories
# forget all that funky code I wrote before; all you have to type is this shit below; it will do the trick;
diff -Naur dir-A dir-B > out.patch
#!/bin/bash
# run with: curl -s http://gist.github.com/265272.txt | bash
set -e
localdir=$HOME/.mongodb
datadir=$localdir/data
conf=$localdir/mongod.conf
agent=$HOME/Library/LaunchAgents/org.mongodb.mongod.plist
brew install mongodb
@leandro
leandro / super.rb
Created December 29, 2009 21:57 — forked from lifo/super.rb
# [] - Eqauls to
# ^ - Not equals to
# =~ - LIKE
# >, >=, <, <= works as expected
#
# Examples :
#
# Item.where(:colour['Red'], :quanity > 10, :price <= 200)
# Post.where(:comments_count >= 1, :taggings_count < 5)
# User.where(:country ^ 'US') # Non american users
# Reincarnation for classes
class Class
def reincarnate
buried = Object.__send__(:remove_const, self.name)
Object.const_set(self.name, Class.new(buried))
end
end
class Abc
class NilClass
def > value
false
end
def <=> value
return 0 if value.nil?
end
alias_method :<, :>
# this should exist natively
# extending strftime for syntatic sugar sake
class Time
def % str
strftime(str)
end
end
# usage