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 / 0-ELFINDER TOKEN AUTHENTICATION, rails, tinymce, elfinder, nginx.md
Last active February 18, 2022 22:06
ELFINDER TOKEN AUTHENTICATION, rails, tinymce, elfinder, nginx

This is an example of using elfinder with bcrypt tokens.

It works like this:

  • backend and elfinder knows about secret token
  • user can access elfinder on localhost:8000/elFinder/elfinder.html, but cant write without token
  • backend adds hashed token to url only on some pages (admin panel for example)
  • tinymce opens elfinder.html in iframe with hashed token, elfinder.html iframe pass this token to connector, connector validates token
  • I use nginx to bypass cors issue

Sorry can provide more elaborate exmaple (proprietary software)

(function(console){
console.save = function(data, filename){
if(!data) {
console.error('Console.save: No data')
return;
}
if(!filename) filename = 'console.json'
if(typeof data === "object"){
data = JSON.stringify(data, undefined, 4)
}
@srghma
srghma / nix override flavours.md
Last active December 29, 2021 19:36
nix override
FFT
https://www.youtube.com/watch?v=spUNpyF58BY - Fourier Transform
You should find what is a freq of a signal (e.g. you should find that it's 3b/s)
you are given signal portion 4.5 s
you can wrap that 4.5 around a circle where
- 1 rotation per 6 seconds = 1/6 rotations per second
@srghma
srghma / 1.md
Last active November 21, 2021 13:01
Near DeFi
stage_ssh () {
ssh \
root@${stage_ip} \
-i ${toString ../secrets/stage_root_key} \
$@
}
state_nixos_rebuild () {
NIX_SSHOPTS="-i ${toString ../secrets/stage_root_key}" \
nixos-rebuild \

Изображение

  1. Стек - особая область памяти, в которой переменные не получают абсолютных адресов, чтобы отградиться от рекурсивных процедур

Изображение (1)

@srghma
srghma / pBFT— Understanding the Consensus Algorithm.md
Created September 4, 2021 10:53
pBFT— Understanding the Consensus Algorithm

download

(1) request: the client sends a request to the master node.

(2) pre-prepared: The master node receives the request from the client and needs to verify whether the signature of the client request message is correct. If correct, a pre-prepare message is broadcast to other replica nodes.

(3) prepared: the replica node receives the pre-prepare message from the master node and carries out verification. If correct, the replica node sends a prepare message to other nodes, including the primary.

original

data DoorState = Open | Closed

data Door : DoorState -> Type where
     MkDoor : (doorId : Int) -> Door st

openDoor : (1 d : Door Closed) -> Door Open
@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