Skip to content

Instantly share code, notes, and snippets.

View simplylizz's full-sized avatar
🏠
Working from home

Anton Yanchenko simplylizz

🏠
Working from home
View GitHub Profile
@simplylizz
simplylizz / scanify.sh
Last active September 28, 2022 11:20
Scanify with imagemagick
#!/bin/bash
convert \
-density 300 \
"${1}" \
-alpha remove \
-rotate 0.33 \
-attenuate 0.15 \
+noise Multiplicative \
+repage \
@simplylizz
simplylizz / lru.py
Last active February 1, 2019 11:06
LRU cache
class Node:
__slots__ = ['left', 'right', 'value', 'key']
def __init__(self, key, value, left=None, right=None):
self.value = value
self.key = key
self.left = left
self.right = right
def insert_left(self, node):
#include <iostream>
#include <vector>
void solution() {
uint N;
std::cin >> N;
uint h_size = N >> 1;
std::vector<long> arr1;
@simplylizz
simplylizz / proxytm.py
Last active September 12, 2015 09:36
Simple Python Proxy™
# coding: utf-8
"""HTTP proxy server based on werkzeug.
Parses content of html responses and adds to all 6-length words tm symbol.
"""
import re
from bs4 import element
@simplylizz
simplylizz / gist:4150361
Created November 26, 2012 20:19
String finder for python code.
"""Parses files in the current dir to find all strings"""
import fnmatch
import os
import ast
class ShowStrings(ast.NodeVisitor):
def visit_Str(self, node):
print node.lineno, node.col_offset, repr(node.s)
@simplylizz
simplylizz / gist:3942365
Created October 23, 2012 23:07
Django choices
class Choices(object):
"""Constants holder and Django field's choices builder. All public
properties would be interpreted as choices.
"""
def __init__(self, **kwargs):
for prop_name, prop_value in kwargs.iteritems():
setattr(self, prop_name, prop_value)
def get_choices(self):