Skip to content

Instantly share code, notes, and snippets.

View pohmelie's full-sized avatar
🐗

Nikita Melentev pohmelie

🐗
  • Tbilisi, Georgia
View GitHub Profile
@pohmelie
pohmelie / text-border.scm
Created December 6, 2022 01:06
«Text border» plugin for GIMP (put it to `~/.config/GIMP/{version}/scripts/`
(script-fu-register "script-fu-text-border"
"Text border..."
"Creates text border"
"Anon"
"Anon"
"2012"
""
SF-IMAGE "Image" 0
SF-DRAWABLE "Layer" 0
SF-COLOR "Color" '(0 0 0)
@pohmelie
pohmelie / docker-trimmer.service
Created September 21, 2020 15:10
Trim docker images for 1 week every sunday 00:00
[Unit]
Description=Prune containers and "old" images (older, than week)
[Service]
ExecStart=/bin/bash -c "docker container prune -f && docker image prune -a -f --filter until=168h"
@pohmelie
pohmelie / app.spec
Last active May 7, 2019 16:14
pyinstaller extended spec with declarative hat
# -*- mode: python -*-
import configparser
import pathlib
import shutil
NAME = "app"
ONE_FILE = False
HIDDEN = [
"module_a",
@pohmelie
pohmelie / output.txt
Created April 27, 2019 10:51
pysnooper gen coro example
Starting var:.. x = 1
Starting var:.. y = 2
13:50:40.798043 call 29 def fib(n):
13:50:40.798187 line 11 z = x + y
New var:....... z = 3
13:50:40.798215 line 12 a = x - y
New var:....... a = -1
13:50:40.798250 line 13 b = a + z
New var:....... b = 2
13:50:40.798271 line 14 result = await the_42()
@pohmelie
pohmelie / nginx-openresty reverse proxy ntlm support.md
Last active December 19, 2022 08:31
nginx/openresty reverse proxy ntlm support

nginx/openresty reverse proxy ntlm support

Problem

This code allows you to pass ntlm auth in nginx reverse proxy mode. The problem with plain nginx is that ntlm requires one tcp connection for multiple http requests. Even if browser respect this behaviour, nginx will create/took new connection for each request to ntlm-awared server.

Solution

Implement nginx-like stream proxy, but parse http to understand end of sequence (first request after ntlm auth). We need end of sequence, since browser can reuse opened tcp connection and send another request, which will be passed to ntlm-aware server and this is not you expect.

Installation

Put ntlm.lua to lualib path of openresty.

Linux

You need to install lua-http-parser into openresty lualib path with luarocks.

Windows

@pohmelie
pohmelie / curry.py
Created November 9, 2018 16:32
Curry weird decorator
import functools
def curry(calls=1):
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
@pohmelie
pohmelie / repack-deb.sh
Last active September 8, 2020 10:37
Repack deb file
#!/usr/bin/env bash
rm -rf tmp
dpkg-deb -R $1 tmp
read -p "Press [enter] when done"
mv $1 $1.original
dpkg-deb -Zgzip -b tmp $1
@pohmelie
pohmelie / build-opencv-for-pyenv.py
Created April 26, 2017 14:46
Build opencv for ubuntu 16.04 with pyenv
import pathlib
import sys
import sh
def clone_if_not_exists(name, url, **kwargs):
if not pathlib.Path(name).exists():
print("Cloning", url, "...")
sh.git.clone(url, name, depth=1, **kwargs)
@pohmelie
pohmelie / result.txt
Created April 5, 2017 12:15
aiozmq XPUB/XSUB example
xpub connection made
xsub connection made
xsub binding tcp://127.0.0.1:45098
pub connection made
xpub binding tcp://127.0.0.1:34462
sub connection made
xpub message received [b'\x01test']
xpub writing [b'\x01test'] to xsub
xsub message received [b'test', b'0']
xsub writing [b'test', b'0'] to xpub
@pohmelie
pohmelie / readme.md
Last active October 30, 2022 03:26
Install opencv3 for python 3.5.0 with pyenv on ubuntu 14.04

Install opencv3 for python 3.5.0 with pyenv on ubuntu 14.04

  • update cmake and install deps as this said.

  • run cmake

    cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=~/.pyenv/versions/3.5.0/usr/local/ \
    -D INSTALL_C_EXAMPLES=OFF \
    -D BUILD_NEW_PYTHON_SUPPORT=ON \