Skip to content

Instantly share code, notes, and snippets.

class A
def something
puts "something in A"
end
end
module B
def self.included(klass)
klass.send :remove_method, :something
end
@marcgg
marcgg / gist:733592
Created December 8, 2010 17:26
Regex to get the Facebook Page ID from a given URL
# Matches patterns such as:
# https://www.facebook.com/my_page_id => my_page_id
# http://www.facebook.com/my_page_id => my_page_id
# http://www.facebook.com/#!/my_page_id => my_page_id
# http://www.facebook.com/pages/Paris-France/Vanity-Url/123456?v=app_555 => 123456
# http://www.facebook.com/pages/Vanity-Url/45678 => 45678
# http://www.facebook.com/#!/page_with_1_number => page_with_1_number
# http://www.facebook.com/bounce_page#!/pages/Vanity-Url/45678 => 45678
# http://www.facebook.com/bounce_page#!/my_page_id?v=app_166292090072334 => my_page_id
# http://www.facebook.com/my.page.is.great => my.page.is.great
javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; var DI= document.getElementsByTagName("img"); DIL=DI.length; function A(){for(i=0; i<DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5+"px"; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5+"px"}R++}tag=setInterval('A()',5 );document.onmousedown=function(){clearInterval(tag);for(i=0; i<DIL; i++){DI[i].style.position="static";}}; void(0)
@marcgg
marcgg / gist:1153638
Created August 18, 2011 08:14
Display SQL log to the Rails console in 2.x
require 'logger'
if ENV.include?('RAILS_ENV') && !Object.const_defined?('RAILS_DEFAULT_LOGGER')
# log SQL to the Rails console
Object.const_set('RAILS_DEFAULT_LOGGER', Logger.new(STDOUT))
end
@marcgg
marcgg / gist:1164759
Created August 23, 2011 09:47
CoffeeScript Syntactic Sugar: console?.log()
console.log("hey")
=> ReferenceError: console is not defined
console?.log("hey")
=> nothing
@marcgg
marcgg / connection_fix.rb
Created December 22, 2011 14:15 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@marcgg
marcgg / gist:2284586
Created April 2, 2012 15:54
URL to add an application on a Facebook Timeline
http://www.facebook.com/dialog/pagetab?app_id=[APP_ID]&redirect_uri=http://[REDIRECT_URL]
This URL might vary. At the time of creating this gist (April 2012), it is working fine.
If the URL changed, please comment and let me know
@marcgg
marcgg / gist:2358135
Created April 11, 2012 09:07
Fix segfault when installing REE with rvm on OSX 10.7
export CC=/usr/bin/gcc-4.2
Content for .zsh:
#########
# COLORS
#########
autoload -U colors
colors
setopt prompt_subst
class BankAccountController
def admin_index
@bbans = Bbans.all
end
def user_index
@bbans_user = current_user.bbans.all
end