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
wget -O init-deb.sh http://library.linode.com/assets/660-init-deb.sh | |
sudo mv init-deb.sh /etc/init.d/nginx | |
sudo chmod +x /etc/init.d/nginx | |
sudo /usr/sbin/update-rc.d -f nginx defaults | |
after that you can control nginx with | |
sudo /etc/init.d/nginx stop | |
sudo /etc/init.d/nginx start | |
sudo /etc/init.d/nginx restart |
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 'database_cleaner' | |
RSpec.configure do |config| | |
config.before(:each) do |example_group| | |
DatabaseCleaner.strategy = if (Capybara.current_driver != :rack_test) | |
[:truncation, { except: %w[statuses] }] | |
else | |
:transaction | |
end | |
DatabaseCleaner.start |
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
class WWW | |
STARTS_WITH_WWW = /^www\./i | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
if env['HTTP_HOST'] =~ STARTS_WITH_WWW |
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
Dir['**/*.rb'].each { |f| | |
s = open(f).read | |
awesome_rx = /(?<!return)(?<!:)(?<!\w)(\s+):(\w+)\s*=>/ | |
count = s.scan(awesome_rx).length | |
next if count.zero? | |
s.gsub!(awesome_rx, '\1\2:') | |
puts "#{count} replacements @ #{f}" | |
open(f, 'w') { |b| b << s } } |
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
describe do | |
describe "Find pages", :sphinx do | |
before { Factory :page, site_ids: [Site.first.id], title: "first", hidden: false } | |
before { Factory :page, site_ids: [Site.last.id], title: "second", hidden: true } | |
before { ThinkingSphinx::Test.index; sleep 1 } | |
specify "should be able to search pages", :js do | |
search_for "first" | |
within ".narrow-col" do |
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 'activerecord-import' | |
class Product < ActiveRecord::Base | |
has_many :product_keywords, dependent: :delete_all | |
def update_product_keywords | |
self.product_keywords.delete_all | |
records = [] | |
title_keywords.each do |keyword| |
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 object_match?(a, b, cmp_key = 'guid') | |
cmp = lambda {|x,y| (x[cmp_key] <=> y[cmp_key]).to_i} | |
if a.kind_of? Hash | |
a.each do |key, value| | |
return false unless object_match?(value, b[key], cmp_key) | |
end | |
elsif a.kind_of? Array | |
a.sort!(&cmp) |
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
# | |
# Copyright (c) Yuri Omelchuk <[email protected]> | |
# | |
# January 8, 2009 | |
# | |
# Maze class written for RubyLearning contest | |
# http://rubylearning.com/blog/2009/12/27/rpcfn-mazes-5/ | |
# | |
# solution is based on find shortest path algorithm | |
# |
NewerOlder