- city
- city_prefix
- city_suffix
- country
- postcode
- secondary_address
- state
class ParamsSlicer | |
def initialize(params, *whitelist) | |
@params = params | |
@nested_whitelist = whitelist.extract_options! | |
@whitelist = whitelist | |
end | |
def call | |
params.slice(*whitelist).tap do |result| | |
nested_whitelist.each do |k, v| |
<?php | |
$chunk = 'tpl.msdfcMsg'; | |
$discounts = array( | |
'100000' => '10%', | |
'150000' => '15%', | |
'200000' => '20%', | |
); | |
krsort($discounts); | |
reset($discounts); | |
$actionKey = 'msdfc_action'; |
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
<?php | |
/* | |
Скрипт надо запускать от юзера - владельца сайта, чтобы созданные файлы пакетов не принадлежали юзеру root | |
$ sudo -u USERNAME php /var/www/USERNAME/packages.php /var/www/USERNAME/www/ | |
Или от root, а после выставить владельца: | |
$ php /root/scripts/modx/packages.php /var/www/USERNAME/www/ && /var/www/USERNAME/chmod | |
Чтобы запустить из веба, просто положите скрипт в корень или куда-нибудь глубже и вызовите по HTTP | |
*/ |
# activerecord-3.0.0/lib/active_record/connection_adapters/mysql_adapter.rb | |
# Maps logical Rails types to MySQL-specific data types. | |
def type_to_sql(type, limit = nil, precision = nil, scale = nil) | |
return super unless type.to_s == 'integer' | |
case limit | |
when 1; 'tinyint' | |
when 2; 'smallint' | |
when 3; 'mediumint' | |
when nil, 4, 11; 'int(11)' # compatibility with MySQL default |
# This is a skeleton for testing models including examples of validations, callbacks, | |
# scopes, instance & class methods, associations, and more. | |
# Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
# | |
# I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
# so if you have any, please share! | |
# | |
# @kyletcarlson | |
# | |
# This skeleton also assumes you're using the following gems: |
module Wysihtml5Helper | |
def fill_in_wysihtml5(text) | |
#js must be enabled | |
page.execute_script("editor.setValue('#{text}')") | |
end | |
end |
Originally published in June 2008
When hiring Ruby on Rails programmers, knowing the right questions to ask during an interview was a real challenge for me at first. In 30 minutes or less, it's difficult to get a solid read on a candidate's skill set without looking at code they've previously written. And in the corporate/enterprise world, I often don't have access to their previous work.
To ensure we hired competent ruby developers at my last job, I created a list of 15 ruby questions -- a ruby measuring stick if you will -- to select the cream of the crop that walked through our doors.
Candidates will typically give you a range of responses based on their experience and personality. So it's up to you to decide the correctness of their answer.
- Add initializer to
config/application.rb
- Add new class to
app/models/spree/calculators/[class_name].rb
- Add logic to class file
Class must have the following methods:
def self.description
"Custom FlexiRate"
end