Skip to content

Instantly share code, notes, and snippets.

View iafonov's full-sized avatar
🌴

Igor Afonov iafonov

🌴
View GitHub Profile
class Class
alias old_new new
def new(*args)
old_new(*args)
end
end
class Shit
def initialize(&block)
class Class
alias old_new new
def new(*args)
old_new(*args)
end
end
class Shit
def initialize(obj)
igor$ macruby lib/application.rb
core:in `dump': nil is not a symbol (TypeError)
from /Library/Frameworks/MacRuby.framework/Versions/0.5/usr/lib/ruby/1.9.0/hotcocoa/mappings/menu.rb:12:in `submenu:'
from core:in `menu:'
from /Users/igor/dev/macruby/sample/lib/menu.rb:3:in `application_menu'
from /Library/Frameworks/MacRuby.framework/Versions/0.5/usr/lib/ruby/1.9.0/hotcocoa/mappings/application.rb:17:in `load_application_menu'
from /Library/Frameworks/MacRuby.framework/Versions/0.5/usr/lib/ruby/1.9.0/hotcocoa/mappings/application.rb:8:in `handle_block:'
from core:in `application:'
from lib/application.rb:in `start'
from lib/application.rb:1:in `<main>'
require 'hotcocoa'
# Replace the following code with your own hotcocoa code
class Application
include HotCocoa
def start
application :name => "Sample" do |app|
-(void)createStatusItem
{
statusItem = [[[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength]
retain];
[statusItem setHighlightMode:YES];
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
NSString *path = [bundle pathForResource:@"icon" ofType:@"png"];
menuIcon= [[NSImage alloc] initWithContentsOfFile:path];
Transaction = Backbone.Model.extend({
allAttributes: function() {
return _(this.attributes).extend(this.virtualAttributes());
},
virtualAttributes: function() {
return { accountFrom: this.accountFrom(), accountTo: this.accountTo(), transactionSumCents: this.transactionSumCents() };
}
})
function test(x) {
return x === 1;
}
if (test(2)) {
print("no")
}
/* AST
# Use @ff_with_basic_auth if you need http basic authorization
Capybara.register_driver :ff_with_basic_auth do |app|
Capybara::Driver::Selenium
profile = Selenium::WebDriver::Firefox::Profile.new
profile['network.http.phishy-userpass-length'] = 1024
Capybara::Driver::Selenium.new(app, { :profile => profile })
end
Before("@ff_with_basic_auth") do
WebMock.allow_net_connect!
Before("@webmock") do
WebMock.disable_net_connect!(:allow_localhost => true)
end
After("@webmock") do
WebMock.allow_net_connect!
end
@iafonov
iafonov / gist:1101460
Created July 23, 2011 14:01
parse the link and put custom host into it
When /^(?:I|they) follow "([^"]*?)" in the email$/ do |link|
def parse_email_for_anchor_text_link(link_text)
if current_email.body =~ %r{<a[^>]*href=['"]?([^'"]*)['"]?[^>]*?>[^<]*?#{link_text}[^<]*?</a>}
URI.split($1)[5..-1].compact!.join("?").gsub("&amp;", "&")
end
end
url_path = parse_email_for_anchor_text_link(link)
visit "http://test1.localhost:31337#{url_path}"