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
# миграции генерятся при генерации модели | |
# $ rails generate model Post title:string content:text author_id:integer | |
# генерирует db/migrate/{TIME}_create_posts.rb | |
class CreatePosts < ActiveRecord::Migration | |
def self.up | |
create_table :posts do |t| | |
t.string :name | |
t.text :content | |
t.integer :author_id | |
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 Fixnum #:nodoc: | |
XChar = Builder::XChar unless defined?(XChar) | |
# XML escaped version of chr (inlines cyrillic unicode range) | |
def xchr | |
n = XChar::CP1252[self] || self | |
n = 42 unless XChar::VALID.find { |value| value.kind_of?(Range) ? value.include?(n) : (value == n) } | |
XChar::PREDEFINED[n] or case n | |
when 0...128 |
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
user www-data; | |
worker_processes 2; | |
error_log /var/log/nginx/error.log; | |
pid /opt/nginx/logs/nginx.pid; | |
events { | |
worker_connections 1024; | |
multi_accept on; |
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 convert_csv_to_yml | |
yaml = [] | |
CSV.foreach('db/seeds/region.csv', {:col_sep => ';'}) do |row| | |
row[2] = row[2].force_encoding('UTF-8') | |
yaml << {:name => row[2], :region_id => row[0], :country_id => row[1]} | |
end | |
yaml.shift | |
File.open('db/seeds/regions.yml', 'w:UTF-8') { |f| f << unescape(YAML.dump(yaml)).force_encoding('UTF-8') }; nil | |
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
user app; | |
worker_processes 2; | |
error_log /home/app/logs/nginx.error.log info; | |
events { | |
worker_connections 1024; | |
} | |
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
# just add a gem dependency for Timecop or require it yourself | |
Given 'the time is $time' do |time| | |
Timecop.freeze Time.parse(time) | |
end | |
When '$time pass' do |time| | |
Timecop.travel future_time(time) | |
Given 'delayed jobs are run' # we use delayed jobs and have some that get scheduled in the future. | |
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
# Put this content to ~/.irbrc file (no extension) | |
require "rubygems" | |
begin | |
require "ap" | |
rescue LoadError => err | |
puts "Cannot find awesome_print gem. Please run 'gem install awesome_print' to install it." | |
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
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: redis-server | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Should-Start: $local_fs | |
# Should-Stop: $local_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: redis-server - Persistent key-value db |
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
ru: | |
errors: | |
messages: | |
not_found: "не найдена" | |
already_confirmed: "уже подтверждена" | |
not_locked: "не заблокирована" | |
devise: | |
sessions: | |
link: 'Вход' |
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
ru: | |
errors: | |
messages: | |
not_found: "не найдена" | |
already_confirmed: "уже подтверждена" | |
not_locked: "не заблокирована" | |
devise: | |
sessions: | |
link: 'Вход' |