Skip to content

Instantly share code, notes, and snippets.

@finist
finist / gist:4123995
Last active October 13, 2015 02:18
postgres
export PATH=/usr/local/bin:$PATH
Start manually:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
Stop manually:
pg_ctl -D /usr/local/var/postgres stop -s -m fast
pg_ctl -D /usr/local/var/postgres status
@finist
finist / gist:6352009
Last active December 21, 2015 19:09
n+1 problem
class User < ActiveRecord::Base
has_many :mails
def messages_for_recipient(user)
mails.where(user_id: user.id).map(&:messages).flatten
end
end
@finist
finist / gist:7433753
Last active February 8, 2020 15:03
Cities of Russia with regions in yaml format
---
- Адыгея:
- Абадзехская
- Адамий
- Адыгейск
- Новая Адыгея
- Нижний Айрюм
- Апостолиди
- Ассоколай
- Кармир-Астх
@finist
finist / ror_ubuntu_16.04.md
Last active June 16, 2021 21:52
Ruby on Rails setup on Ubuntu 16.04
upstream app {
# Path to Puma SOCK file, as defined previously
server unix://srv/servername/shared/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
server_name servername;
# listen 443 ssl;
@finist
finist / ansible_ror.md
Last active February 8, 2020 19:56
Setup Ruby on Rails application to remote server with Ansible

Установка Ruby on Rails приложения на удаленный сервер с помощью Ansible

Установка Ansible на Ubuntu 16.04

подключаемся к серверу и ставим Ansible

sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDCceFZtbCWXTIyICGN+fEcmW9tJITAU1Wdpf/+no79ZwMkvb6gdM3fAAVPdTvc8aZbJvKTFk/dVukDonf/5p8woAyDD6aZX1PHbND1n1o6kgMY69IHVUntFuKihHSKJ7DKdj3Braa9VTPlYzVysDxINp/NXWBg+mfPqFJDHibBIzR7SwIIQSt4SYr97xEzf7DPiXkNeXHT8vqD4L5jSHwFne55XegMla1Cvvy/tNMQ6+IFe1SLePPRWaTEMZ+RoF41RqBKCpFVRkxpblBq9N/AbON6Xs0ngtyjK58hTgNYr8H0uTC/cp4lzjOErxruJlZDBFG0FQ5bznHaSGp60P7L finist@21sm
@finist
finist / _field.html.erb
Last active August 31, 2023 11:00
Rails Stimulus autocomplete
<%# views/application/autocomplete/_field.html.erb %>
<div
data-controller="autocomplete"
data-autocomplete-multiple-value=true
data-autocomplete-search-path-value=<%= local_assigns[:search_path] %>
data-autocomplete-search-param-value=<%= local_assigns[:search_param] %>
data-autocomplete-selected-class="bg-n42-blue text-white"
data-action="autocomplete:click:outside->autocomplete#hide"
class="relative"