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
>> c.orders.each(&:destroy) | |
=> [#<Order id: 73712, store_id: 6, customer_id: 11115, number: "SYR120073712", order_status_id: 3, product_total: 66.528, discount_total: 16.632, tax_total: 0.0, shipping_total: nil, total_cost: 69.028, created_at: "2012-03-29 14:19:29", updated_at: "2012-03-29 14:19:30", shipping_first_name: nil, shipping_last_name: nil, shipping_company: nil, shipping_address1: nil, shipping_address2: nil, shipping_city: nil, shipping_state: nil, shipping_postal_code: nil, shipping_phone: nil, ups_label_id: 53546, state_tax_total: 0.0, postal_tax_total: 0.0, discount_rate: nil, product_total_min: 0.0, ups_service_minimum_charge_version: nil, is_fedex: true, fedex_tracking_number: "793394008065", service_type: "PRIORITY_OVERNIGHT", dim_weight: 2.0>, #<Order id: 73708, store_id: 6, customer_id: 11115, number: "SYR120073708", order_status_id: 3, product_total: 2.5, discount_total: nil, tax_total: 0.14, shipping_total: 9.75, total_cost: 12.39, created_at: "2012-03-29 13:51:02", updated_at: "2012-03- |
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 self.search(params) | |
orders = self | |
orders = orders.scoped(:conditions => {:service_type => params[:service_type]}) if params[:service_type].present? | |
orders = orders.scoped(:conditions => ['orders.created_at >= ?', params[:date_range_start]]) if params[:date_range_start].present? | |
orders = orders.scoped(:conditions => ['orders.created_at <= ?', params[:date_range_end]]) if params[:date_range_end].present? | |
orders.all | |
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
irb(main):048:0> module P | |
irb(main):049:1> def a; puts 'a'; end | |
irb(main):050:1> module_function :a | |
irb(main):051:1> end | |
=> P | |
irb(main):052:0> P.a | |
a | |
=> nil | |
irb(main):053:0> P::a | |
a |
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
import java.util.ArrayList; | |
public class AkariDaisukiDiv2 { | |
ArrayList<String[]> ar = new ArrayList<String[]>(); | |
String ss; | |
private boolean eq(String[] a, String[] res) { | |
if (a.length != res.length) { |
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
public class AkariDaisukiDiv2 { | |
public int countTuples(String s) { | |
if (s.length() < 4) { | |
return 0; | |
} | |
int res = 0; | |
for (int i = 2; i < s.length() - 2; i++) { | |
for (int j = i + 2; j < s.length(); j++) { | |
String s1 = s.substring(0, i); | |
String s2 = s.substring(i, j); |
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 enum(*values, &class_body) | |
Class.new( Class.new(&class_body) ) do | |
attr_reader :ordinal | |
def initialize(ordinal, *args, &blk) | |
super(*args, &blk) | |
@ordinal = ordinal | |
end | |
values.each_with_index do |(name, *parameters), i| |
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
require "csv_corrector/version" | |
require "tempfile" | |
module CsvCorrector | |
def correct(file_path) | |
temp = Tempfile.new([File.basename(file_path, '.*'), '.csv'], File.dirname(file_path)) | |
begin | |
File.open(file_path) do |file| | |
file.each do |line| | |
line.gsub!(/"(.*?)"\,/).each { |m| %Q["#{$1.gsub /"/, "'"}",] } |
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
Feature: User should be able to login when he enters valid username/password and vice versa | |
Scenario Outline: User should have access to the system | |
Given the folloving customer exist in current store: | |
| Email | Password | Password Confirmation | | |
| <Email> | <Password> | <Password Confirmation> | | |
And I am on the login page | |
When I fill in the following: | |
| login-email | [email protected] | |
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
по всем файлам "*.png" рекурсивно | |
для найденного файла | |
преобразовать файл из png в jpg формат не изменяя его расширения |
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
1. rails new <name> --skip-bundle --database=mysql --skip-test-unit --old-style-hash | |
2. delete vendor folder | |
3. delete doc folder | |
4. delete rails.png | |
5. delete public/index.html | |
6. create config for db | |
7. change application.rb to do not generate helpers/assets and etc. waste files |