Skip to content

Instantly share code, notes, and snippets.

View gist:6222393
class BankAccountController
def admin_index
@bbans = Bbans.all
end
def user_index
@bbans_user = current_user.bbans.all
end
View gist:2644116
Content for .zsh:
#########
# COLORS
#########
autoload -U colors
colors
setopt prompt_subst
@marcgg
marcgg / gist:2358135
Created Apr 11, 2012
Fix segfault when installing REE with rvm on OSX 10.7
View gist:2358135
export CC=/usr/bin/gcc-4.2
@marcgg
marcgg / gist:2284586
Created Apr 2, 2012
URL to add an application on a Facebook Timeline
View gist:2284586
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 / connection_fix.rb
Created Dec 22, 2011 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
View connection_fix.rb
# 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:1164759
Created Aug 23, 2011
CoffeeScript Syntactic Sugar: console?.log()
View gist:1164759
console.log("hey")
=> ReferenceError: console is not defined
console?.log("hey")
=> nothing
@marcgg
marcgg / gist:1153638
Created Aug 18, 2011
Display SQL log to the Rails console in 2.x
View gist:1153638
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
View gist:827432
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:733592
Created Dec 8, 2010
Regex to get the Facebook Page ID from a given URL
View gist:733592
# 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
View gist:579420
class A
def something
puts "something in A"
end
end
module B
def self.included(klass)
klass.send :remove_method, :something
end