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
export GEMDIR=`gem env gemdir`
gemdoc() {
open $GEMDIR/doc/`$(which ls) $GEMDIR/doc | grep $1 | sort | tail -1`/rdoc/index.html
}
mategem() {
mate $GEMDIR/gems/`$(which ls) $GEMDIR/gems | grep $1 | sort | tail -1`
}
_gemdocomplete() {
COMPREPLY=($(compgen -W '$(`which ls` $GEMDIR/doc)' -- ${COMP_WORDS[COMP_CWORD]}))
return 0
class Asset < ActiveRecord::Base
class << self
def method_missing(meth, *args, &blk)
if asset = first(:conditions => {:name => meth.to_s})
asset.value
else
super
end
end
# How to paste code in Keynote
1. Load code in Textmate
2. Select Bundle Item (Ctrl + Cmd + T) -> Create HTML from Document
3. Preview (Ctrl + Cmd + P)
4. Select All (Cmd + A), Copy (Cmd + C)
5. Paste in Keynote but also save the code because editing is a little nightmare
require 'rubygems'
require 'benchmark'
require 'almodovar' # http://github.com/bebanjo/almodovar
auth = Almodovar::DigestAuth.new("Sequence", "api_user", "secret")
sequence = Almodovar::Resource("http://sequence.local/api", auth)
sequence.work_areas.first.name
# "Bebanjo TV"
$ curl -u api_user --digest http://sequence.local/api/work_areas/52/jobs/12897?expand=tasks
Enter host password for user 'api_user': *****
<?xml version='1.0' encoding='utf-8' ?>
<job>
<name>My new job</name>
<due-date type='date'>2010-06-18T00:00:00+02:00</due-date>
<status>pending</status>
<tasks-status>pending</tasks-status>
<assets-status>received</assets-status>
def wadus(wadus = nil, options = {})
puts "wadus = #{wadus.inspect}"
puts "options = #{options.inspect}"
end
wadus
# wadus = nil
# options = {}
# OK
@porras
porras / why_steak.md
Created January 8, 2011 14:48
Why Steak (over Cucumber)

Why Steak (over Cucumber)

From here

  • Plain text have no value if people writing and reading the specs are developers. Code is natural language for developers (specially if that code is Ruby). Having a client who reads the specs is a possible situation and Cucumber is cool there, but in my experience that situation is not the most common one. If in your case there's no value in having your specs in English rather than in Ruby, Cucumber is an additional layer of abstraction in exchange of nothing.

  • There's a myth about clients writing the specs. It sounds like a unicorn to me, but let's take it. Still, I wouldn't want it. Clients are experts in problems, I am expert in solutions. I want the client to describe the problem I have to solve, not to describe the solution.

  • Some people say Cucumber is cool because you write the stories, the client validates them, and then you can start developing. That is not Agile. The on

require 'mrproper'
# assuming Croupier.normal(i, m = 0, v = 1) returns an array of i elements following a normal distribution with mean m and variance v
properties 'normal(i, m, v)' do
data :i => 1..9999,
:m => -10.0..10.0,
:v => 0.0..10.0
property 'has i elements' do |data|
Last login: Sat Jun 16 20:24:37 on ttys014
sergio@reykjavik:~ $ ping sis.sermepa.es
PING sis.sermepa.es (195.76.9.149): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6
Request timeout for icmp_seq 542
Request timeout for icmp_seq 543
Request timeout for icmp_seq 544
Request timeout for icmp_seq 545
Request timeout for icmp_seq 546
Request timeout for icmp_seq 547
Request timeout for icmp_seq 548
Request timeout for icmp_seq 549
Request timeout for icmp_seq 550
Request timeout for icmp_seq 551