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

Keybase proof

I hereby claim:

  • I am srghma on github.
  • I am srghma (https://keybase.io/srghma) on keybase.
  • I have a public key ASD1MDtsbC5cqzbn5RevzNhsStSznnYts4jteE43idPIAwo

To claim this, I am signing this object:

@srghma
srghma / 1.Как стать программистом.md
Last active January 6, 2024 06:31
как стать программистом

fix function - https://github.com/NixOS/nixpkgs/blob/9f087964709174424bca681b600af8ee8e763df5/lib/fixed-points.nix#L19 , https://en.m.wikipedia.org/wiki/Fixed_point_(mathematics) , point where x = f(x) = f(f(f(f....f(x)....)))

rec { a = 1; b = a + 1; } is the same as fix (self: { a = 1; b = self.a + 1; })

builtins.trace - https://github.com/NixOS/nixpkgs/blob/9f087964709174424bca681b600af8ee8e763df5/lib/debug.nix#L4 trace has different flavors, http://hackage.haskell.org/package/base-4.12.0.0/docs/Debug-Trace.html#v:trace all lazy languages have trace

builtins.seq - in lazy languages data is represented as thunks (IF data has not been yet evaluated THEN it's pointer on function that should produce this data ELSE it's pointer on data), builtins.seq forces first layer of data to evaluate (evaluates it to WHNF?), builtins.deepSeq is recursive variant of seq, it forces whole data to evaluate (evaluates it to NF?), (more https://wiki.haskell.org/Seq, https://www.google.com/amp/s/amp.reddit.

@srghma
srghma / nix override flavours.md
Last active December 29, 2021 19:36
nix override
@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 / 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 / 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 / setup_ubuntu_instance.sh
Last active May 22, 2021 11:08 — forked from kopiro/install-docker.sh
Install Docker + Docker-compose on Ubuntu
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
apt-cache policy docker-ce
sudo apt-get install -y docker-ce
sudo curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m)"
sudo chmod +x /usr/local/bin/docker-compose
sudo usermod -a -G docker $USER
# reenter ssh
@srghma
srghma / setup_centos_instance.sh
Last active April 15, 2019 12:06 — forked from 0sc/aws-go+docker-setup.sh
Setup script for golang, docker and docker-compose on Amazon Linux AMI 2017.09.0 (HVM) on EC2
#!bin/sh
# Update installed packages and package cache
sudo yum update -y
# make sure in the home folder
cd ~/
# Golang installation