This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
OmniAuth.config.test_mode = true | |
OmniAuth.config.mock_auth[:facebook] = { | |
"uid" => '12345', | |
"provider" => 'facebook', | |
"user_info" => {"name" => "Test Pepito", "nickname" => 'pepito'}, | |
"credentials" => {"token" => 'testest'} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'active_record' | |
require 'sqlite3' | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'sqlite3', | |
:database => ':memory:' | |
) | |
ActiveRecord::Schema.define do | |
create_table :users do |t| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require 'active_record' | |
require 'sqlite3' | |
ActiveRecord::Base.establish_connection( | |
:adapter => 'sqlite3', | |
:database => ':memory:' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
length = 12 | |
rand(36**length).to_s(36) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Spork.prefork do | |
# ... your normal prefork block goes here ... | |
module Kernel | |
def require_with_trace(*args) | |
start = Time.now.to_f | |
@indent ||= 0 | |
@indent += 2 | |
require_without_trace(*args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Update 7 Oct 2010: | |
# - This example does *not* appear to work with Chrome >=6.0. Apparently, | |
# the WebSocket protocol implementation in the cramp gem does not work | |
# well with Chrome's (newer) WebSocket implementation. | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some helpers | |
function unique (array) { | |
var a = []; | |
var l = array.length; | |
for(var i=0; i<l; i++) { | |
for(var j=i+1; j<l; j++) { | |
// If array[i] is found later in the array | |
if (array[i] === array[j]) | |
j = ++i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some helpers | |
function unique (array) { | |
var a = []; | |
var l = array.length; | |
for(var i=0; i<l; i++) { | |
for(var j=i+1; j<l; j++) { | |
// If array[i] is found later in the array | |
if (array[i] === array[j]) | |
j = ++i; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function LousyTemp(text) { | |
var code = '%>' + text + '<%'; | |
code = code | |
.replace(/[\n\r\t]/g," ") | |
.replace(/(["'])/g, '\\$1') | |
.replace(/<%=(.*?)%>/g, "', $1, '") | |
.replace(/%>(.*?)<%/g, "_t_.push('$1'); "); | |
code = "obj||(obj={}); var _t_ = []; with(obj) {" + code + "}; return _t_.join('');"; | |
return new Function('obj', code); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inside the inbox page | |
outer = $('.left-column') | |
inner = $('.headers') | |
offset = inner.height() - outer.height() - 50 | |
scroll_pos = outer.scrollTop() | |
if scroll_pos > offset | |
# The scroll bar is at the end! |
OlderNewer