Skip to content

Instantly share code, notes, and snippets.

Content for .zsh:
#########
# COLORS
#########
autoload -U colors
colors
setopt prompt_subst
@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
@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 / 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: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 / 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
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)
class A
def something
puts "something in A"
end
end
module B
def self.included(klass)
klass.send :remove_method, :something
end
@marcgg
marcgg / flow-matic
Last active August 29, 2015 14:14
flow-matic
(0) INPUT INVENTORY FILE-A PRICE FILE-B ; OUTPUT PRICED-INV FILE-C UNPRICED-INV
FILE-D ; HSP D .
(1) COMPARE PRODUCT-NO (A) WITH PRODUCT-NO (B) ; IF GREATER GO TO OPERATION 10 ;
IF EQUAL GO TO OPERATION 5 ; OTHERWISE GO TO OPERATION 2 .
(2) TRANSFER A TO D .
(3) WRITE-ITEM D .
(4) JUMP TO OPERATION 8 .
(5) TRANSFER A TO C .
(6) MOVE UNIT-PRICE (B) TO UNIT-PRICE (C) .
(7) WRITE-ITEM C .
require 'benchmark'
ActiveRecord::Base.logger = nil
ActiveRecord::Schema.verbose = false
ActiveRecord::Migration.verbose = false
# PARAMS
sql = ""
attributes = []