Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴

Igor Afonov iafonov

🌴
View GitHub Profile
View gist:59441
class Class
alias old_new new
def new(*args)
old_new(*args)
end
end
class Shit
def initialize(&block)
View gist:59443
class Class
alias old_new new
def new(*args)
old_new(*args)
end
end
class Shit
def initialize(obj)
View gist:213276
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>'
View gist:213279
require 'hotcocoa'
# Replace the following code with your own hotcocoa code
class Application
include HotCocoa
def start
application :name => "Sample" do |app|
View gist:224275
-(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];
View gist:719979
Transaction = Backbone.Model.extend({
allAttributes: function() {
return _(this.attributes).extend(this.virtualAttributes());
},
virtualAttributes: function() {
return { accountFrom: this.accountFrom(), accountTo: this.accountTo(), transactionSumCents: this.transactionSumCents() };
}
})
View v8_ast_example.js
function test(x) {
return x === 1;
}
if (test(2)) {
print("no")
}
/* AST
View gist:992874
# 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
View gist:992876
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 Jul 23, 2011
parse the link and put custom host into it
View gist:1101460
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}"