Skip to content

Instantly share code, notes, and snippets.

View padi's full-sized avatar

Marc Ignacio padi

View GitHub Profile
@padi
padi / shell
Created September 6, 2011 06:44
How to lose your merge commit
marcrendlignacio:~/RebaseAfterMerge: development$ git log -p
commit 36b2f0ddba699197acfb4540bfe21113342e6c2a
Merge: 2e51d47 17e1525
Author: Padi Ignacio <[email protected]>
Date: Tue Sep 6 14:18:46 2011 +0800
Merge branch 'feature-1' into development <<< watch this commit disappear.
commit 17e1525836ca186b7936a81dd6a4a6b6b2b0b0bc
Author: Padi Ignacio <[email protected]>
@padi
padi / tubigNaAso.rb
Created September 9, 2011 18:25
Tubig na Aso
class Aso
def initialize(name)
@name = name
end
end
class TubigNaAso < Aso
def initialize name
@name = "TubigNa" + name
end
Then /^there should be a report "([^"]*)" with the condition "([^"]*)" from (?:"([^"]*)"|anonymous)$/ do |text, condition, username|
Report.last.text.should == text
Report.last.conditions.should == [condition]
Report.last.username.should == username
end
@padi
padi / jquery.validate.remote_spec.js
Created September 28, 2011 13:11
where do i put the function that runs the same tests? (lines 42-52 and 62-72)
describe("jQuery validate remote option", function() {
var body, form;
beforeEach(function() {
body = $('body');
spyOnEvent(body, 'signup:timeout');
spyOnEvent(body, 'signup:connecting');
spyOnEvent(body, 'signup:timeoutRecovery');
@padi
padi / Commentary
Created September 29, 2011 06:46
shared examples stored under spec/javascripts/.
I tried the basic idea from thoughtbot as much as possible (it uses Underscore.js, but I think I don't need it yet)
So do I need to be able to pass all the needed variables (like body) from the jquery.validate.remote_spec to window.sharedExamples?
@padi
padi / report.rb
Created October 5, 2011 02:03
Rake Task for Updating Conditions
desc 'Update traffic condition'
task :update_condition => :environment do
Report.all.each do |report|
report.update_attribute(:conditions, Tweet.new(report).conditions) unless report.user
end
end
@padi
padi / numeric.rb
Created October 7, 2011 16:17
Improvement in defining methods.
class Numeric
[['multiply', '*'], ['divide', '/'], ['add', '+'], ['subtract', '-']].each do |method, operator|
define_method("#{method}_10") do
method(operator).call(10) # line not readable, should be something like self + 10, self - 10, etc...
end
end
end
puts 40.add_10
puts 40.subtract_10
@padi
padi / main_spec.rb
Created October 2, 2012 07:38
RubyMotion spec sample
describe "RubyMotion App" do
before do
@app = UIApplication.sharedApplication
end
it "has one window" do
@app.windows.size.should == 1
end
end
@padi
padi / big.rb
Created November 23, 2012 12:00
yo method so fat
yo method so fat, the Global Interpreter Lock (GIL) can't stop it
yo method so fat, it doesn't fit in 1 thread. In fact, it takes up 8 of them.
yo method so fat, the garbage collector had to make 10 trips! - buddy
yo models so fat, its factory definition had to named FactoryYoMama, - buddy
yo method so fat, it eats up all the memory (no seriously, open your CPU ... ) (incomplete) - buddy
yo method so fat, _________
Add suggestions in the comments :P