Skip to content

Instantly share code, notes, and snippets.

Nikita Melentev pohmelie

Block or report user

Report or block pohmelie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@pohmelie
pohmelie / app.spec
Last active May 7, 2019
pyinstaller extended spec with declarative hat
View app.spec
# -*- mode: python -*-
import configparser
import pathlib
import shutil
NAME = "app"
ONE_FILE = False
HIDDEN = [
"module_a",
@pohmelie
pohmelie / output.txt
Created Apr 27, 2019
pysnooper gen coro example
View output.txt
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 Aug 19, 2019
nginx/openresty reverse proxy ntlm support
View nginx-openresty reverse proxy ntlm support.md

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 Nov 9, 2018
Curry weird decorator
View curry.py
import functools
def curry(calls=1):
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwargs):
View repack-deb.sh
#!/usr/bin/env bash
rm -rf tmp
dpkg-deb -R $1 tmp
read -p "Press [enter] when done"
mv $1 $1.original
dpkg-deb -b tmp $1
@pohmelie
pohmelie / build-opencv-for-pyenv.py
Created Apr 26, 2017
Build opencv for ubuntu 16.04 with pyenv
View build-opencv-for-pyenv.py
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 Apr 5, 2017
aiozmq XPUB/XSUB example
View result.txt
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 Jun 11, 2019
Install opencv3 for python 3.5.0 with pyenv on ubuntu 14.04
View readme.md

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 \
    
@pohmelie
pohmelie / aio.lua
Last active Nov 16, 2015
aio — primitive asyncio-like coroutines scheduler
View aio.lua
local M = {}
M.tasks = {}
function M.yield(...)
return coroutine.yield({args=table.pack(...)})
end
@pohmelie
pohmelie / rubattle-D2-online.md
Last active Aug 29, 2015
PG (rubattle.net) diablo II players online
View rubattle-D2-online.md

PG (rubattle.net) diablo II players online

Grabs snapshots of rubattle.net from «wayback machine» (thanks for API ;) and gets the online of Diablo II LOD server. Split results by UTC time of snapshot (don't forget UTC+4 cause moscow) by three groups. Build some nice graph to svg via pygal.

Requirements

  • python3
  • requests
  • beautifulsoup4
  • pygal

Result

result

You can’t perform that action at this time.