Skip to content

Instantly share code, notes, and snippets.

@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] }
@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

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 / trix_reconfigure.coffee
Created December 4, 2016 14:56
Конфигурация для Trix WYSIWYG редактора.
Trix.config.lang =
bold: "Жирный"
bullets: "Маркерованный список"
byte: "Байт"
bytes: "Байты"
captionPlaceholder: "Введите описание здесь…"
captionPrompt: "Добавить описание…"
code: "Код"
heading1: "Заголовок"
indent: "Увеличить уровень"
### 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 / 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
@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 / HOWTO.md
Created December 4, 2017 22:47 — forked from cvan/HOWTO.md
How to serve a custom HTTPS domain on GitHub Pages with CloudFlare: *FREE*, secure and performant by default

Instructions

CloudFlare is an awesome reverse cache proxy and CDN that provides DNS, free HTTPS (TLS) support, best-in-class performance settings (gzip, SDCH, HTTP/2, sane Cache-Control and E-Tag headers, etc.), minification, etc.

  1. Make sure you have registered a domain name.
  2. Sign up for CloudFlare and create an account for your domain.
  3. In your domain registrar's admin panel, point the nameservers to CloudFlare's (refer to this awesome list of links for instructions for various registrars).
  4. From the CloudFlare settings for that domain, enable HTTPS/SSL and set up a Page Rule to force HTTPS redirects. (If you want to get fancy, you can also enable automatic minification for text-based assets [HTML/CSS/JS/SVG/etc.], which is a pretty cool feature if you don't want already have a build step for minification.)
  5. If you
@artanikin
artanikin / xterm-256color-italic.terminfo
Last active May 4, 2018 06:23 — forked from sos4nt/xterm-256color-italic.terminfo
A xterm-256color based TERMINFO that adds the escape sequences for italic
# A xterm-256color based TERMINFO that adds the escape sequences for italic.
#
# Install:
#
# tic xterm-256color-italic.terminfo
#
# Usage:
#
# export TERM=xterm-256color-italic
#
= surround '(', ')' do
%a{ href: "food" } chicken
-# Produces:
-# (<a href='food'>chicken</a>)
= succeed '.' do
%a{ href: "thing" } here
-# Produces:
-# <a href='thing'>here</a>.