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
| >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-] | |
| >++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++ | |
| .------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++. |
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 Kernel | |
| def scoped_extend(obj, method_name, method_body, &blk) | |
| stored_method = nil | |
| if (obj.respond_to? method_name) | |
| stored_method = obj.method(method_name) | |
| end | |
| eigenclass = class << obj | |
| self | |
| end | |
| eigenclass.send(:define_method, method_name, &method_body) |
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 you are doing this (effectively) | |
| a = {:action => "list", :notice => "yay"} | |
| redirect_to a | |
| #you want to be doing this | |
| a = {:action => "list"} | |
| b = {:notice => "yay"} | |
| redirect_to a, b | |
| #which you can do by explicitly adding the braces around the URL stuff, like so | |
| redirect_to {:action => "list"}, :notice => "yay" |
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
| def get_ij(m, n) | |
| (m*n).times do |i| | |
| i,j = i.divmod(n) | |
| if test(i,j) | |
| yield i,j and return | |
| end | |
| 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 Class | |
| def self.attr_accessor_defaults(attrs) | |
| attrs.each do |k, v| | |
| attr_writer(k) | |
| define_method(k) { instance_variable_defined?("@#{k}") ? instance_variable_get("@#{k}") : v } | |
| end | |
| 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
| module Kernel | |
| attr_accessor :__defaults | |
| def attr_accessor_defaults(attributes) | |
| attr_accessor(*attributes.keys) | |
| @__defaults ||= {} | |
| @__defaults.merge!(attributes) | |
| end | |
| private :attr_accessor_defaults |
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
| def is_url(str) | |
| u = URI.parse(str) | |
| u.class == URI::HTTP || u.class == URI::HTTPS | |
| rescue URI::InvalidURIError | |
| false | |
| 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
| resource :account do | |
| resource :table do | |
| collection do | |
| get 'projects' | |
| end | |
| 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
| Easygram::Application.routes.draw do | |
| resources :templates | |
| resources :clients do | |
| resources :users | |
| member do | |
| get "templates" => "clients#templates" | |
| post "templates" => "clients#templates_save" | |
| end | |
| end | |
| resources :telegrams, :controller => :messages, :only => [:index, :new] |
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
| include ActionView::Helpers::FormOptionsHelper | |
| include ActionView::Helpers::TagHelper | |
| counties = [["England", ["Bedfordshire", "Berkshire", "Bristol", "Buckinghamshire", "Cambridgeshire", "Cheshire", "Cornwall", "Cumbria", "Derbyshire", "Devon", "Dorset", "Durham", "East Yorkshire", "East Sussex", "Essex", "Gloucestershire", "Greater Manchester", "Hampshire", "Herefordshire", "Isle of Wight", "Kent", "Lancashire", "Leicestershire", "Lincolnshire", "London", "Merseyside", "Norfolk", "North Yorkshire", "Northamptonshire", "Northumberland", "Nottinghamshire", "Oxfordshire", "Rutland", "Shropshire", "Somerset", "South Yorkshire", "Staffordshire", "Suffolk", "Surrey", "Tyne & Wear", "Warwickshire", "West Midlands", "West Sussex", "West Yorkshire", "Wiltshire", "Worcester"]], ["Northern Ireland", ["County Antrim", "County Armagh", "County Down", "County Fermanagh", "County Londonderry", "County Tyrone"]], ["Scotland", ["Aberdeenshire", "Angus", "Argyll & Bute", "Clackmannanshire", "Dumfries & Galloway", "Dundee", " |