Skip to content

Instantly share code, notes, and snippets.

@the-sanjar
the-sanjar / deployUser.md
Created June 15, 2019 11:33 — forked from learncodeacademy/deployUser.md
Adding a deploy user in Linux

(wherever it says url.com, use your server's domain or IP)

Login to new server as root, then add a deploy user

sudo useradd --create-home -s /bin/bash deploy
sudo adduser deploy sudo
sudo passwd deploy

And Update the new password

@the-sanjar
the-sanjar / shortid.rb
Created June 14, 2019 12:43 — forked from DarrenN/shortid.rb
Short unique ID (Ruby)
t = DateTime
id = t.now.strftime("%Y%m%d%k%M%S%L") # Get current date to the milliseconds
id = id.to_i.to_s(36) # will generate somthing like "5i0sp1h4tkc"
# Reverse it
id.to_i(36)
@the-sanjar
the-sanjar / circle.yml
Created June 7, 2019 11:37 — forked from masutaka/circle.yml
capistrano deployment using CircleCI 2.0
version: 2
jobs:
build:
docker:
- image: ruby:2.3.3-alpine
working_directory: /home/circleci/masutaka.net
steps:
- setup_remote_docker:
# https://circleci.com/docs/2.0/docker-layer-caching/
reusable: true
@the-sanjar
the-sanjar / cap.md
Created May 23, 2019 05:17
capistrano deploy

Capistrano Deploy (Nginx + Passenger) on Ubuntu 16.04+

Install

Ruby & Dependencies

# Install dependencies
sudo apt-get update
sudo apt-get install build-essential libssl-dev libyaml-dev libreadline-dev openssl curl git-core zlib1g-dev bison libxml2-dev libxslt1-dev libcurl4-openssl-dev nodejs libsqlite3-dev sqlite3

# Install RVM
@the-sanjar
the-sanjar / devise.ru.yml
Created May 11, 2019 07:40 — forked from EvilFaeton/ devise.ru.yml
Russian I18n locale for devise.
ru:
devise:
confirmations:
confirmed: "Ваша учётная запись подтверждена. Теперь вы вошли в систему."
send_instructions: "В течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
send_paranoid_instructions: "Если ваш адрес email есть в нашей базе данных, то в течение нескольких минут вы получите письмо с инструкциями по подтверждению вашей учётной записи."
failure:
already_authenticated: "Вы уже вошли в систему."
inactive: "Ваша учётная запись ещё не активирована."
invalid: "Неверный адрес email или пароль."
# Русский перевод для https://github.com/plataformatec/devise/tree/v1.4.7
# Другие переводы на http://github.com/plataformatec/devise/wiki/I18n
ru:
errors:
messages:
expired: "устарела. Пожалуйста, запросите новую"
not_found: "не найдена"
already_confirmed: "уже подтверждена. Пожалуйста, попробуйте войти в систему"
not_locked: "не заблокирована"
@the-sanjar
the-sanjar / pre-push
Created May 2, 2019 12:31 — forked from chalmagean/pre-push
Pre-Push git hook to run specs before pushing
#!/bin/sh
# Put it in .git/hooks/pre-push
branch=`git rev-parse --abbrev-ref HEAD`
exit_code=$(bundle exec rspec --fail-fast --out /dev/null --format progress > /dev/null 2>/dev/null )$?
if [ $exit_code -gt 0 ]
then echo "Did not push because of failing tests"
fi
#!/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] }