This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
=begin | |
Created by keyvan | |
#newznab on irc.synirc.net | |
This script is for importing a giant dump of NZB files into newznab. Be warned, it's HACKY! | |
1) I expect you have downloaded a big archive full of nzbs and have extracted it. | |
The directory structure should be like this: | |
dump/ | |
MoviesHD/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# I didn't know gists were not editable by multiple people when i first wrote this... oh well. | |
class GistFile | |
def initialize(filename, gist_id) | |
@filename = filename | |
@file = File.new(filename) | |
@gist_id = gist_id | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSArray *) NSArrayOfNSDictionariesOfSize:(int)size { | |
NSMutableArray *returnedArray = blah bla bla | |
for(int i=size;i<size;i++) | |
create a dictionary, stuff it in the returnedArray at position i | |
return returnedArray; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module UserAbilities | |
def can?(verb, target) | |
Ability[verb].call(self, verb, target) | |
end | |
Ability = { | |
:use=>lambda { |user, verb, target| | |
# This depends primarily on what the target is. | |
Target[target.class.to_s].call(user, verb, target) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Hstore Method Missing Extension | |
module HstoreModel | |
def method_missing(method, *args, &block) | |
if !self.class.attribute_methods_generated? | |
self.class.define_attribute_methods | |
if respond_to_without_attributes?(method) | |
send(method, *args, &block) | |
else | |
super | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
guard 'spork', :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do | |
watch('config/application.rb') | |
watch('config/environment.rb') | |
watch('config/environments/test.rb') | |
watch(%r{^config/initializers/.+\.rb$}) | |
watch('Gemfile') | |
watch('Gemfile.lock') | |
watch('spec/spec_helper.rb') { :rspec } | |
watch('test/test_helper.rb') { :test_unit } | |
watch(%r{features/support/}) { :cucumber } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PolymorphicThing | |
# I am trying to prevent duplicate records as such. | |
validates :user_id, :uniqueness => {:scope => [:verb, :resource_type, :resource_id]} | |
end | |
# It works but there must be a better way to prevent dupes? | |
# The fields referenced are the only columns on this table |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/keyvan/Projects/Hokkaido/lib/motion_mock.rb:11:in `require': cannot load such file -- /Users/keyvan/Code/cucumber/lib/Users/keyvan/Code/cucumber/lib/cucumber.rb (LoadError) | |
from /Users/keyvan/Projects/Hokkaido/lib/motion_mock.rb:11:in `<<' | |
from /Users/keyvan/Code/cucumber/lib/cucumber.rb:33:in `block in <main>' | |
from /Users/keyvan/Projects/Hokkaido/lib/motion_mock.rb:15:in `call' | |
from /Users/keyvan/Projects/Hokkaido/lib/motion_mock.rb:15:in `setup' | |
from /Users/keyvan/Code/cucumber/lib/cucumber.rb:30:in `<main>' | |
The #require removal was not a success. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write_manifest | |
correct_load_order_array = [] | |
load_last = [] | |
@require_libs_hash.each do |root_file, nested_requires| | |
# Fix path for root files (needed since we derive from path and not a #require line) | |
load_last << root_file.gsub(lib_folder+File::SEPARATOR, '') | |
correct_load_order_array << nested_requires.reverse.flatten | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[12] pry(#<Hokkaido::GemModifier>)> @require_libs_hash | |
=> {"/Users/keyvan/Code/cucumber/lib/cucumber.rb"=> | |
["cucumber/broadcaster", "cucumber/step_definitions"], | |
"/Users/keyvan/Code/cucumber/lib/cucumber/platform.rb"=>[], | |
"/Users/keyvan/Code/cucumber/lib/cucumber/parser.rb"=>["cucumber/ast"], | |
"/Users/keyvan/Code/cucumber/lib/cucumber/ast.rb"=> | |
["cucumber/ast/comment", | |
"cucumber/ast/features", | |
"cucumber/ast/feature", | |
"cucumber/ast/background", |
OlderNewer