Skip to content

Instantly share code, notes, and snippets.

View nplusp's full-sized avatar
🌸

Mikita Pridorozhko nplusp

🌸
View GitHub Profile
@nplusp
nplusp / nginx.conf
Created May 6, 2016 13:08 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
ps ax | grep PROCESS_NAME | awk '{print "kill -9 " $1}'
lsof -Pn -i4 | grep LISTEN
# Hash in params
def product_params
properties_keys = params[:product].try(:fetch, :properties, {}).keys
params.require(:product).permit(:title, :description, properties: properties_keys)
end
# Nested hash in params
def item_params
params.require(:item).permit(values: permit_recursive_params(params[:item][:values]))
end
@nplusp
nplusp / gist:d46d9cd3f07673e21ecfbb626d6199ad
Created January 27, 2017 12:51
run scripts on Heroku
echo "puts User.count" | heroku run console --app=my-heroku-app --no-tty
cat some_script.rb | heroku run console --app=my-heroku-app --no-tty
heroku run bundle exec rails runner ./scripts/script.rb -a my-heroku-app
heroku run bash
@nplusp
nplusp / gist:6299f5cdca45b42506f76c64376f5e26
Created March 13, 2017 11:34
Speed up your bundle install
bundle config --global jobs 3 # Number of cores - 1
@nplusp
nplusp / gist:34aad8df58974eb2b15162a5d26b0776
Last active March 13, 2017 13:31
using SSH over HTTPS for CircleCI to fix authentication issues
checkout:
post:
# Work around some silly configuration added by Circle that doesn't actually even do what they want it to.
- git config --global --unset url.ssh://[email protected]:.insteadof
@nplusp
nplusp / gist:b6ebd6998e03d9cee83e46f174faab31
Created August 9, 2017 13:59
Catch slow queries in Postgres
cat /etc/postgresql/9.6/main/postgresql.conf | grep log_min_duration_statement
#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
log_min_duration_statement = 100
sudo tail -f /var/log/postgresql/postgresql-9.6-main.log
@nplusp
nplusp / ssl_puma.sh
Created July 12, 2018 16:16 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key