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
var x = 31 | |
var y = 13 | |
x = x + y | |
y = x - y | |
x = x - y |
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 UIKit | |
struct Card { | |
var symbolsCount = 1 | |
var shape: Shape = .shapeOne | |
var color: Color = .colorOne | |
var filling: Filling = .filled | |
enum Shape { | |
case shapeOne, shapeTwo, shapeThree |
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
------------------------------ | |
******************** | |
CONFIDENT RUBY | |
******************** | |
------------------------------ | |
каждый метод может состоять максимум из 4 частей | |
1 Collecting input | |
2 Performing work | |
3 Delivering output |
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
module Resourceable | |
extend ActiveSupport::Concern | |
included do | |
helper_method :resource, :resources, :resource_class | |
end | |
def index; end | |
def show; 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
Алгоритмы: | |
1) Стивен Скиена "Алгоритмы. Руководство по разработке" | |
2) Томас Кормен "Алгоритмы. Построение и анализ" | |
3) Дональд Кнут "Искусство программирования" (никто в реальности не читал этот многотомный труд целиком, но в любой подборке по алгоритмам он обязан быть) | |
Общее: | |
1) Род Хаггарти "Дискретная математика для программистов" | |
2) Керниган, Ритчи "Язык программирования С" - для общего понимания принципов программирования | |
3) Дж. Андресон "Дискретная математика и комбинаторика" | |
4) Романовский И.В. "Дискретный анализ" |
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
# paths | |
app_path = "/home/deployer/qna" | |
working_directory "#{app_path}/current" | |
pid "#{app_path}/current/tmp/pids/unicorn.pid" | |
# listen | |
listen "/tmp/unicorn.qna.sock", :backlog => 64 | |
# logging | |
stderr_path "log/unicorn.stderr.log" |
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
### Nginx ### | |
check process nginx with pidfile /opt/nginx/logs/nginx.pid | |
start program = "/etc/init.d/nginx start" | |
stop program = "/etc/init.d/nginx stop" | |
if cpu > 60% for 2 cycles then alert | |
if cpu > 80% for 5 cycles then restart | |
if memory usage > 80% for 5 cycles then restart | |
if failed host 127.0.0.1 port 80 protocol http | |
then restart | |
if 3 restarts within 5 cycles then timeout |
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
### Unicorn ### | |
check process unicorn | |
with pidfile "/home/deployer/qna/current/tmp/pids/unicorn.pid" | |
start program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exec unicorn -c /home/deployer/qna/current/config/unicorn/production.rb -E deployment -D'" | |
stop program = "/bin/su - deployer -c 'cd /home/deployer/qna/current && /home/deployer/.rvm/bin/rvm default do bundle exeс kill -s USR2 `cat /home/deployer/qna/current/tmp/pids/unicorn.pid`'" | |
if memory usage > 90% for 3 cycles then restart | |
if cpu > 90% for 2 cycles then restart | |
if 5 restarts within 5 cycles then timeout | |
### Nginx ### |
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
class Ability | |
include CanCan::Ability | |
def initialize(user) | |
if user | |
can :create, [Question, Answer, Attachment, Comment] | |
can %i[update destroy], [Question, Answer], user_id: user.id | |
can :destroy, Comment, user_id: user.id | |
can :destroy, Attachment, attachable: { user_id: user.id } |
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 'rails_helper' | |
RSpec.describe Ability do | |
subject(:ability) { Ability.new(user) } | |
describe "for guest" do | |
let(:user) { nil } | |
it { should be_able_to :read, :all } | |
it { should_not be_able_to :manage, :all } |