Skip to content

Instantly share code, notes, and snippets.

View forsaken1's full-sized avatar
💭
Elixir one love

Alex Krylov forsaken1

💭
Elixir one love
View GitHub Profile
@forsaken1
forsaken1 / kaminari.ru.yml
Last active August 29, 2015 14:19
Перевод локалей для kaminari
ru:
helpers:
page_entries_info:
more_pages:
display_entries: "Показана %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> из <b>%{total}</b>"
one_page:
display_entries:
few: "Показаны <b>%{count}</b> %{entry_name}"
many: "Показаны <b>%{count}</b> %{entry_name}"
one: "Показано <b>%{count}</b> %{entry_name}"
@forsaken1
forsaken1 / Capfile
Created April 29, 2015 04:36
Capistrano 3 deploy with Unicorn and Nginx
# Load DSL and set up stages
require 'capistrano/setup'
# Include default deployment tasks
require 'capistrano/deploy'
require 'capistrano/unicorn_nginx'
require 'rvm1/capistrano3'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
@forsaken1
forsaken1 / servername.conf
Last active August 29, 2015 14:24
Конфиг для nginx как фронтэнд сервера для приложения, запущенном на определенном порту
server {
listen 80;
server_name www.servername.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
@forsaken1
forsaken1 / resource.rb
Last active August 29, 2015 14:25
Active admin tricks
form do |f|
f.has_many :images, allow_destroy: true, new_record: true do |fi|
fi.input :file, as: :file, hint: (f.template.image_tag(f.object.file.url(:small)) if f.object.file.present?)
end
end
@forsaken1
forsaken1 / array.rb
Last active September 29, 2015 00:24
Ruby monkey patching
class Array
# [1, 2, 3, 4, 5, 6, 7, 8].to_columns 1, 2, 3, 2 => [[1], [2, 3], [4, 5, 6], [7, 8]]
def to_columns *column_counts
return [] if self.empty?
result, start_iterator, end_iterator = [], 0, 0
column_counts.each do |column_count|
end_iterator = start_iterator + column_count
cut = self[start_iterator...end_iterator]
result << cut unless cut.nil?
start_iterator += column_count
@forsaken1
forsaken1 / aliases.sh
Last active April 4, 2019 16:04
git aliases for *nix
alias s="git status"
alias a="git add"
alias c="git commit -m"
alias p="git push origin"
alias pu="git pull origin"
alias ch="git checkout"
alias cb="git checkout -b"
alias cl="git clone"
alias di="git diff"
alias am="git commit --amend"
@forsaken1
forsaken1 / SocketIO.js
Created March 17, 2016 11:30
Small wrapper over WebSocket
function SocketIO(url) {
this.socket = new WebSocket(url);
this.actions = {};
var self = this;
this.socket.onmessage = function(event) {
var name, message;
[name, message] = self.parse_data(event.data);
self.actions[name](message)
}
@forsaken1
forsaken1 / commands
Created September 8, 2016 01:18
Sinatra Thin nginx config
service nginx start
thin start -s 2 -C /etc/thin/myapp.yml -R config.ru
thin restart -C /etc/thin/myapp.yaml
@forsaken1
forsaken1 / gist:4a1a4d432a2d2ab793bb11a1573ef57e
Created February 21, 2017 18:09
Nginx phoenix config with basic auth
upstream uphill_rating {
server 127.0.0.1:4000;
}
server{
listen 80;
server_name uphill.krylov-alexey.ru;
location / {
try_files $uri @proxy;
}
aws s3 sync s3://production… /tmp/s3/ --profile production
aws s3 sync /tmp/s3/ s3://boss-strapping-stage/ --profile stage --acl public-read