Skip to content

Instantly share code, notes, and snippets.

@vesh95
vesh95 / Module.rb
Created November 26, 2019 04:41
Ruby module mixin template
module Name
def self.included(base)
base.extend ClassMethods
base.send :include, InstanceMethods
end
module ClassMethods
end
module InstanceMethods
@vesh95
vesh95 / rubocop_pre_commit_hook
Created November 28, 2019 09:23 — forked from palkan/rubocop_pre_commit_hook
Rubocop pre-commit hook
#!/usr/bin/env ruby
ADDED_OR_MODIFIED = /^\s*(A|AM|M)/.freeze
changed_files = `git status --porcelain`.split(/\n/)
unstaged_files = `git ls-files -m`.split(/\n/)
changed_files = changed_files.select { |f| f =~ ADDED_OR_MODIFIED }
changed_files = changed_files.map { |f| f.split(" ")[1] }
GET /anything HTTP/1.1
Host: httpbin.org
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: *
Content-Type: application/json
Date: Fri, 06 Dec 2019 13:57:33 GMT
Referrer-Policy: no-referrer-when-downgrade
Server: nginx
@vesh95
vesh95 / CRUD.sql
Last active December 8, 2019 15:49
sql
INSERT INTO categories (title) VALUES
('Frontend'),
('Backend'),
('Other');
INSERT INTO tests(title, level, categories_id) VALUES
('HTML', 1, 1),
('Rails', 2, 2),
('Django', 2, 2),
('MySQL', 3, NULL),
#! /bin/sh
PROJECT_BASE=/var/www/[project_name]
GIT_REPO=$PROJECT_BASE/shared/[project_name].git
TMP_GIT_CLONE=$PROJECT_BASE/shared/build
GEMFILE=$TMP_GIT_CLONE/Gemfile
PUBLIC_WWW=$PROJECT_BASE/current
mkdir -p $TMP_GIT_CLONE
git clone $GIT_REPO $TMP_GIT_CLONE
@vesh95
vesh95 / test-guru-question.txt
Created January 15, 2020 20:17
A question about ReactJS from TestGuru
Что делает setState?
Обновляет состояние компонента
Возвращает текущее состояние компонента
@vesh95
vesh95 / test-guru-question.txt
Created January 16, 2020 17:05
A question about Ruby from TestGuru
Что вернёт метод select
Первый попавшийся элемент в массиве
Подмассив, соответствующий условию выборки
Количество подходящих элементов
Случайный массив
#показ ветки в командной строке
parse_git_branch() {
if ! git rev-parse --git-dir > /dev/null 2>&1; then
return 0
fi
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p')
echo "$git_branch"
}
PS1="${debian_chroot:+($debian_chroot)}\e[01;94mbranch:[\$(parse_git_branch)]\e[00m \e[02;31;01mjobs:\j\e[00m \e[01;32m\w\e[00m\n$: "
@vesh95
vesh95 / g1
Created February 13, 2020 13:45
Gistfile1
# frozen_string_literal: true
require 'rails_helper'
RSpec.configure do |config|
config.use_transactional_fixtures = false
# DatabaseCleaner settings
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)