Skip to content

Instantly share code, notes, and snippets.

View srghma's full-sized avatar

Serhii Khoma srghma.github.io/how-life-was-created srghma

View GitHub Profile
@srghma
srghma / notes
Created December 29, 2017 16:45
aws
# connect
ssh centos@pubip_or_dns
ssh -i ~/.ssh/amazon/us-east-1 centos@pubip_or_dns
# add local key
paste ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys
# filezilla
https://forums.aws.amazon.com/thread.jspa?messageID=741338 but interactive
@srghma
srghma / fn.js
Created January 18, 2018 11:21
doAsyncOnSubmit
function doAsyncOnSubmit(form, asyncFn) {
const onSubmitFunction = async function(e) {
e.preventDefault()
form.off('submit', onSubmitFunction)
const doSubmit = await asyncFn()
if (doSubmit) {
form.submit()
@srghma
srghma / Postgraphile questions
Last active February 27, 2018 11:50
Postgraphile questions
Solved questions:
- how to send email after calling function? - postgres listen, notify
Unsolved questions:
- postgresql multidispatch functions?
- how to upload image and save it in db? (maybe schema stitching)
- rails like polymorphic relations?
- how to make vdare like role permissions?
export DB_NAME=
export DB_USER=
mysqldump -p -u "$DB_USER" "$DB_NAME" | gzip > "$HOME/$DB_NAME-backup-$(date +%F).sql.gz"
bcrypt examples in ruby and php
@srghma
srghma / Makefile
Last active June 11, 2018 19:47
nixops files from some of my project
make_dhparam:
openssl dhparam -out backend/dhparams.pem 2048
nixops_create:
nixops create '<base.nix>'
nixops_purge:
nixops destroy --all
nixops delete --all
@srghma
srghma / Server crashes Ive experienced and their causes.md
Last active July 23, 2018 13:19
Server crashes Ive experienced and their causes

Rails, bad configuration

We thought it was memory leak, but it was bad configuration

configuration that didnt work before:

  1. puma (RAILS_MAX_THREADS: 8, WEB_CONCURRENCY: 8)
  2. db pool - 10
  3. memory cache
@srghma
srghma / chosen-select-with-add-new.js
Created July 27, 2018 13:01
chosen select multiple
$(".chosen-select-with-add-new").chosen({
no_results_text: "Click Enter or Tab to add new option",
width: '100%'
}).parent().find('.chosen-container .search-field input[type=text]').keydown(function (evt) {
// get keycode
const stroke = evt.which != null ? evt.which : evt.keyCode;
// If enter or tab key
if (stroke === 9 || stroke === 13) {
const target = $(evt.target);
// get the list of current options
@srghma
srghma / 1.what I have learned, while doing XXX1.md
Last active August 2, 2018 14:08
what I have learned, while doing XXX

Project specification:

ecommerce + news

Technologies: