This file contains hidden or 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 ActiveRecord | |
| module Validations | |
| module ClassMethods | |
| def validates_as_date(*attr_names) | |
| configuration = { | |
| :message => 'is invalid date format', | |
| :allow_nil => true } | |
| # configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash) | |
| debugger | |
| validates_each(attr_names, configuration) do |record, attr_name, value| |
This file contains hidden or 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
| AWS::S3::Base.establish_connection!( | |
| :access_key_id => ENV['AMAZON_ACCESS_KEY_ID'], | |
| :secret_access_key => ENV['AMAZON_SECRET_ACCESS_KEY'] | |
| ) | |
| def remote_serve(file_content, ext = "html", expires_in = 60 * 60 * 2 * 365) | |
| # To generate a unique filename to avoid name colision | |
| filename = Digest::SHA1.hexdigest(file_content + Time.now.to_s) + "." + ext.to_s | |
| bucket_name = 'RemoteAccess' | |
| obj = AWS::S3::S3Object.store(filename, file_content, bucket_name) |
This file contains hidden or 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 RemoteCopy | |
| def rmcp(filename) | |
| s3_connect | |
| full_path = File.expand_path(filename) | |
| basename = File.basename(full_path) | |
| S3Object.store("file_name.txt", basename, 'RemoteClipboard') | |
| S3Object.store("content", File.open(full_path), 'RemoteClipboard') | |
| end |
This file contains hidden or 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
| # Currently running gems | |
| gems = Gem.loaded_specs.map{|name, spec| [name, spec.version.version]} | |
| extend Hirb::Console | |
| table gems |
This file contains hidden or 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
| require 'tempfile' | |
| def vi(txt, arguments_str = "") | |
| Tempfile.open('rubyview') do | file | | |
| file << txt | |
| file.close | |
| cmd = "vim #{arguments_str} \"#{file.path}\"" | |
| system( cmd ) | |
| end | |
| end |
This file contains hidden or 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 BlankSlate | |
| instance_methods.each { |m| undef_method m unless m =~ /^__/ } | |
| end | |
| class MyProxy < BlankSlate | |
| def initialize(obj, &proc) | |
| @proc = proc | |
| @obj = obj | |
| end |
This file contains hidden or 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
| # Tmp files | |
| *.orig | |
| *.swp | |
| *.dot | |
| # Source control files | |
| .hgignore | |
| .hg* | |
| **/*.svn | |
| .svn |
This file contains hidden or 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
| source_url=source_url.com | |
| app_name=app_name | |
| # We download the full webside content | |
| wget --mirror -r $source_url | |
| # We move the web content into the rack public folder | |
| mkdir -p $app_name/public | |
| mv $source_url/* $app_name/public | |
| rm -rf $source_url |
This file contains hidden or 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
| git remote rm heroku | |
| git remote add heroku [email protected]:newname.git |
This file contains hidden or 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
| require 'ruby2ruby' | |
| require 'parse_tree' | |
| ######################### | |
| # Description: Dumps class source. Does not work for some core class. | |
| # | |
| # Example: MyClass.code | |
| # | |
| ######################## | |
| require 'ruby2ruby' |