Skip to content

Instantly share code, notes, and snippets.

View porras's full-sized avatar

Sergio Gil Pérez de la Manga porras

View GitHub Profile
gem 'turbolinks', git: 'git://github.com/porras/turbolinks.git', branch: 'disable-url-management'
Given /^I randomly fail (\d+)% of the time$/ do |i|
r = rand
t = i.to_i / 100.0
raise 'RandomFailure' if r < t
end

Twitter公式クライアントのコンシューマキー

Twitter for iPhone

Consumer key: IQKbtAYlXLripLGPWd0HUA
Consumer secret: GgDYlkSvaPxGxC4X8liwpUoqKwwr3lCADbz8A7ADU

Twitter for Android

Consumer key: 3nVuSoBZnx6U4vzUxf5w
Consumer secret: Bcs59EFbbsdF6Sl9Ng71smgStWEGwXXKSjYvPVt7qys

Twitter for iPad

Consumer key: CjulERsDeqhhjSme66ECg

@porras
porras / .bash_profile
Created June 25, 2013 08:29
Changing terminal color in MacOSX when SSHing
# Changing terminal color in MacOSX when SSHing (so you know at a glance that you're no longer in Kansas)
# Adapted from http://www.rngtng.com/2011/01/14/mac-os-x-terminal-visual-indication-for-your-ssh-connection/
# 1. Create a theme in your terminal setting with the name "SSH" and the desired colors, background, etc.
# 2. Add this to your .bash_profile (or .bashrc, I always forget the difference ;))
# 3. Optional but useful: in the terminal, go to Settings > Startup and set "New tabs open with" to
# "default settings" (otherwise, if you open a new tab from the changed one, you get a local tab with
# the SSH colors)
function tabc() {
NAME=$1; if [ -z "$NAME" ]; then NAME="Default"; fi # if you have trouble with this, change
class FancyDSL
def initialize(&block)
instance_eval(&block)
end
def setup(value)
@setup = value
end
end
irb(main):001:0> class A; private; attr_reader :a; end
=> nil
irb(main):002:0> A.new.a
NoMethodError: private method `a' called for #<A:0x007fbbca0403c0>
from (irb):2
from /Users/sergiogil/.rbenv/versions/1.9.3-p448/bin/irb:12:in `<main>'
class A
private
def self.a
:a
end
end
class B
class << self
@porras
porras / gist:5d4010a254635cedbb6e
Created August 19, 2014 07:59
Fun with dates
>> require 'date'
=> true
>> Date.today.next_month
=> #<Date: 2014-09-19 (4913839/2,0,2299161)>
>> Date.today.next_month - 1
=> #<Date: 2014-09-18 (4913837/2,0,2299161)>
>> Date.today.next_month -1
=> #<Date: 2014-07-19 (4913715/2,0,2299161)>
@porras
porras / config.ru
Created October 2, 2014 13:35
Run your objects as web apps in an insanely decoupled way
class Object
def to_app
lambda do |env|
_, method, args = env['REQUEST_PATH'].split('/')
[200, {}, [self.send(method, *args).to_s]]
end
end
end
class HelloWorld
@porras
porras / gist:75926319d9e157fd4000
Created November 6, 2014 16:18
Wrapping an object that reads in a wrapper you can write to
class ObjectThatInsistsOnCallingRead
def initialize(io)
while s = io.read(10)
print s
end
end
end
class WrapperToWhichYouCanWrite
def initialize