http://guides.rubyonrails.org/migrations.html
- add_column
- add_index
- change_column
- change_table
- create_table
- drop_table
| # /payment_methods/ | |
| # /payment_methods/obt/request.rb | |
| # /payment_methods/obt/notification.rb | |
| # /payment_methods/skrill/request.rb | |
| # /payment_methods/skrill/notification.rb | |
| # /payment_methods/base_request.rb | |
| # /payment_methods/base_notification.rb | |
| # /payment_provider.rb | |
| module PaymentMethods |
| module PaymentMethods | |
| class Base | |
| def request_url(params) | |
| raise 'Not implemented' | |
| end | |
| def response_notification | |
| raise 'Not implemented' | |
| end | |
| end |
| class QuestionRow | |
| def initialize(internal_id: nil, chapter: nil, position: nil, text: nil, images: nil, video: nil, explanation: nil, | |
| error_points: nil, prerequisite_id: nil, external_id: nil, choices: nil) | |
| method(__method__).parameters.each do |type, name| | |
| if type == :key | |
| instance_variable_set "@#{name}", eval("#{name}") | |
| self.class.class_eval { attr_reader name} | |
| end | |
| end | |
| end |
| SELECT objects.name FROM objects JOIN object_types ON objects.object_type_id = object_types.object_type_id AND object_types.name = 'Building' WHERE NOT EXISTS (SELECT params.object_id FROM params, attributes WHERE objects.object_id = params.object_id AND attributes.attr_id = params.attr_id AND attributes.name = 'E-mail' AND params.text_value REGEXP '^[0-9a-zA-Z_\.\-]+@.*\.[a-z]+$') |
| =Navigating= | |
| visit('/projects') | |
| visit(post_comments_path(post)) | |
| =Clicking links and buttons= | |
| click_link('id-of-link') | |
| click_link('Link Text') | |
| click_button('Save') | |
| click('Link Text') # Click either a link or a button | |
| click('Button Value') |
| require 'singleton' | |
| class MailgunConnector | |
| include Singleton | |
| attr_reader :api_key | |
| def client(api_key=settings.mailgun_key) | |
| if @api_key == api_key && @api_key | |
| @client |
http://guides.rubyonrails.org/migrations.html
| #!/usr/bin/env ruby | |
| progress = 'Progress [' | |
| 1000.times do |i| | |
| # i is number from 0-999 | |
| j = i + 1 | |
| # add 1 percent every 10 times | |
| if j % 10 == 0 |
| sudo cp /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage.original | |
| # for Mountain Lion 10.8.3 - 10.8.4 | |
| sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x54)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage | |
| # for Mountain Lion 10.8.1-10.8.2 and Lion 10.7.5 | |
| #sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x4D)|$1\x00\x00\x00\x00\x00\x00\x00\x00\x00$2|sg' /System/Library/Extensions/IOAHCIFamily.kext/Contents/PlugIns/IOAHCIBlockStorage.kext/Contents/MacOS/IOAHCIBlockStorage | |
| # for Mountain Lion 10.8.0 and Lion 10.7.4 BELOW | |
| #sudo perl -pi -e 's|(\x52\x6F\x74\x61\x74\x69\x6F\x6E\x61\x6C\x00{1,20})[^\x00]{9}(\x00{1,20}\x51)| |
| #VBScript | |
| #For J = 1 To N | |
| #term1 = J * (1 - (-1) ^ J * Exp(-Alpha * L)) / (J ^ 2 * 9.869604401 + Alpha ^ 2 * L ^ 2) | |
| #term2 = Exp((-0.5 * implied_volatility ^ 2 * (3.141592654 * J / L) ^ 2 - Beta) * T) | |
| #term3 = Sin((3.141592654 * J / L) * Log(Asset_Price / Lower_Strike)) | |
| #Value(J) = term1 * term2 * term3 | |
| #Agg = Agg + Value(J) | |
| #Next J | |