Skip to content

Instantly share code, notes, and snippets.

@alpody
alpody / haproxy_rate_limiting.md
Created July 14, 2022 08:05 — forked from procrastinatio/haproxy_rate_limiting.md
Rate limiting with HAproxy

Introduction

So HAProxy is primalery a load balancer an proxy for TCP and HTTP. But it may act as a traffic regulator. It may also be used as a protection against DDoS and service abuse, by maintening a wide variety of statistics (IP, URL, cookie) and when abuse is happening, action as denying, redirecting to other backend may undertaken ([haproxy ddos config], [haproxy ddos])

@alpody
alpody / cors.js
Last active November 9, 2021 11:51
Allow access for json-server from any origins
module.exports = (req, res, next) => {
res.header('Access-Control-Allow-Origin', '*')
res.header('Access-Control-Allow-Method','GET HEAD PUT PATCH POST DELETE')
res.header('Access-Control-Allow-Headers', 'Origin,Content-Type,Accept,Authorization')
res.header('Vary', 'Origin, Access-Control-Request-Method, Access-Control-Request-Headers')
next()
}
docker run --rm -v /home/mypictures:/home bperel/terminalimageviewer -256 myimage.png
@alpody
alpody / sh
Created May 27, 2021 19:45
get list fil in ./jobs/1/income/ and check it occurance in ./jobs/1/data.html file
find ./jobs/1/docs/income -type f -print | while read filename ; do a=$(echo $filename | sed 's@./jobs/1/docs/income/@@'); grep $a ./jobs/1/data.html ; done | wc -l
@alpody
alpody / dmesg
Created November 14, 2018 09:36
Dmesg settings console output on/off
#Off output
dmesg -D
#on output
dmesg -E
when i try
docker swarm init --advertise-addr=192.168.56.105
I got message:
Error response from daemon: --live-restore daemon configuration is incompatible with swarm mode
I edit docker config
vi /etc/sysconfig/docker
and remove --live-restore options
@alpody
alpody / gist:27690be5312e589e3d2d561020de6667
Last active May 27, 2023 13:03
export all keybindings in vim to file
"verbose show file which produce remap keybinding
:redir! > vim_keys.txt
:silent verbose map
:redir END
@alpody
alpody / gist:efa0f141bbc718af8f0f5a6179885cc7
Created October 18, 2016 07:03
Add line numbers to every line in vim
:%s/^/\=printf("%04d\t", line('.'))
@alpody
alpody / gist:0e604f6978601394a3e722560559df9a
Created June 20, 2016 14:55
Find "Word" in files and copy them to append and save directory structure
grep -rl 'Word' | cpio -pdm ./append
@alpody
alpody / gist:1e64ce3304e3f1719f65419561446edd
Last active June 20, 2016 06:44
Find file with bom and remove BOM from the files
grep -rl $'\xEF\xBB\xBF'
# remove file with bom
# if remove .bak then sed not create backup
find . -type f -exec sed '1s/^\xEF\xBB\xBF//' -i.bak {} \; -exec rm {}.bak \;