Skip to content

Instantly share code, notes, and snippets.

View poustovitss's full-sized avatar

Serhii Pustovit poustovitss

View GitHub Profile
@poustovitss
poustovitss / .gitconfig
Created February 11, 2019 13:14 — forked from johnpolacek/.gitconfig
My current .gitconfig aliases
[alias]
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
dmerged = "git branch --merged | grep -v '\\*' | xargs -n 1 git branch -d"
st = status
forum_ids = [1,2,3] # given forum ids
forum_ids.map do |forum_id|
Post.joins(:topic).where(topics: { forum: forum_id }).pluck(:subject, 'posts.*').last
end
@poustovitss
poustovitss / tree.rb
Last active July 27, 2018 16:57
tree
max_asterisks_in_row = 15
number_of_asterisk = 1.step(max_asterisks_in_row, 2) # arithmetic progression with step of 2
number_of_asterisk.each do |asterisk|
spaces = " " * ((max_asterisks_in_row - asterisk) / 2) # spaces before and after asterisk
asterisks = "*" * asterisk # number of asterisk
puts spaces + asterisks + spaces
end
heroku login
heroku create app_name
heroku buildpacks:set heroku/ruby
@poustovitss
poustovitss / gist:3654c22d1331462ee2c8847bc5f07cab
Created April 25, 2018 11:43
SSL for server on Ubuntu 16.04 with Nginx
1. Generate a CSR and Private key: `openssl req -newkey rsa:2048 -nodes -keyout example.com.key -out example.com.csr`
2. Enter Common Name with your domain name: example.com
3. cat example.com.csr
4. Copy it to your CA (comodo)
5. Get SSL certificates from the CA (Comodo in my case):
It has 4 certificates in it: AddTrustExternalCARoot.crt /
COMODORSAAddTrustCA.crt /
COMODORSADomainValidationSecureServerCA.crt /
your_domain_name.crt
6. Make copy of AddTrustExternalCARoot.crt and rename it to: intermediate.crt
@poustovitss
poustovitss / .travis.yml
Created April 15, 2018 17:06
Multiple test suites in .travis.yml
gemfile:
- Gemfile
- components/app_component/Gemfile
script:
- travis_retry ./test.sh
before_install:
- cd $(dirname $BUNDLE_GEMFILE)
rvm:
- 2.3.1
@poustovitss
poustovitss / redis_sidekiq_capistrano_rails.txt
Last active April 10, 2018 15:41
Redis + Sidekiq + Capistrano + Rails
###########################################################################################
Redis:
wget http://download.redis.io/redis-stable.tar.gz
tar xvzf redis-stable.tar.gz
rm redis-stable.tar.gz
cd redis-stable
make
sudo cp src/redis-server /usr/local/bin/
sudo cp src/redis-cli /usr/local/bin/
cd
I am the owner of lvh.me. And I'm glad to hear it's helpful. In truth, it's just a fancy DNS trick. lhv.me and all of it's sub-domains just point back to your computer (127.0.0.1). That means running ssl is as simple (or difficult) as running ssl on your computer.
I'm not sure how comfortable you are with the command line, but here's my how I setup my development environment. (rvm, passenger, nginx w/ SSL, etc).
# Install rvm (no sudo!)
# ------------------------------------------------------
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )
source ~/.rvm/scripts/rvm
rvm install ree-1.8.7-2010.02
@poustovitss
poustovitss / create cbra
Created March 28, 2018 08:45
How to create default CBRA (component based rails application)
rails new app
cd app
rm -r app
mkdir components
rails plugin new components/app_component --full --mountable
cd components/app_component
rails g controller welcome index
fix app.component.gemspec
nano /components/app_component/config/routes.rb
add there: «root to: "welcome#index»
@poustovitss
poustovitss / sidekiq.service
Created March 23, 2018 12:41 — forked from mkhuda/sidekiq.service
Sidekiq service auto start for Ubuntu 16.04 using Systemd
#
# Sidekiq auto start using systemd unit file for Ubuntu 16.04
#
# Put this in /lib/systemd/system (Ubuntu).
# Run:
# 1. systemctl enable sidekiq (to enable sidekiq service)
# 2. systemctl {start,stop,restart} sidekiq (to start sidekiq service)
#
# This file corresponds to a single Sidekiq process. Add multiple copies
# to run multiple processes (sidekiq-1, sidekiq-2, etc).