Skip to content

Instantly share code, notes, and snippets.

@artanikin
artanikin / ssl_puma.sh
Created October 9, 2017 06:22 — forked from nathancolgate/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key
$ cd ~/.ssh
$ openssl genrsa -des3 -passout pass:x -out lvh.me.pass.key 2048
# 2) Generate RSA key
$ openssl rsa -passin pass:x -in lvh.me.pass.key -out lvh.me.key
# 3) Get rid of private key
$ rm lvh.me.pass.key
@artanikin
artanikin / tmux-cheatsheet.markdown
Created August 14, 2017 06:47 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
### 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
@artanikin
artanikin / trix_reconfigure.coffee
Created December 4, 2016 14:56
Конфигурация для Trix WYSIWYG редактора.
Trix.config.lang =
bold: "Жирный"
bullets: "Маркерованный список"
byte: "Байт"
bytes: "Байты"
captionPlaceholder: "Введите описание здесь…"
captionPrompt: "Добавить описание…"
code: "Код"
heading1: "Заголовок"
indent: "Увеличить уровень"

Setup

Replace IRB with Pry (in your Gemfile) and Byebug with pry-byebug.

gem 'pry-rails', group: [:development, :test]
gem 'pry-byebug', group: [:development, :test]

Using PRY

@artanikin
artanikin / bootstrap_pagination_helper.rb
Created October 21, 2016 19:05
Will_paginate bootstrap 4 renderer
module BootstrapPaginationHelper
class LinkRenderer < WillPaginate::ActionView::LinkRenderer
protected
def page_number(page)
if page == current_page
link(page, "#", :class => 'active')
else
link(page, page, :rel => rel_value(page))
end
@artanikin
artanikin / rubocop_pre_commit_hook
Created August 30, 2016 13:04 — 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] }