Skip to content

Instantly share code, notes, and snippets.

@dundee
dundee / abspath.py
Created November 9, 2022 15:12
Python script for adding absolute paths to Gdu report
#!/usr/bin/env python3
"""
Usage: gdu -f- | python3 abspath.py
"""
import json
import sys
def processDir(data, path):
path = (path + '/' if path else '') + data[0]['name']
@dundee
dundee / purge_docker_images.py
Last active November 20, 2018 10:02
Purge old docer images from registry
import argparse
import logging
import re
import subprocess
import sys
try:
import pydor
except ImportError:
print('Plese run:')
@dundee
dundee / .bashrc
Last active October 8, 2017 10:14
Colorful bash prompt with git integration
if [[ ${EUID} == 0 ]]; then
PS1="\[\e[41;30m\] \w \${?/#0}\[\e[31;49m\]"$'\xee\x82\xb0'"\[\e[00m\] "
else
PS1="\[\e[44;30m\] \w \[\\e[31m\]\${?/#0}"
PS1="$PS1\$(\
export GIT_BRANCH=\"\$(git branch --no-color 2>/dev/null | sed -n 's/*[^ ]* //p')\"; \
if [ -n \"\$GIT_BRANCH\" ] ; then \
echo -en \"\[\e[43;34m\]\xee\x82\xb0 \"
echo -en \"\[\e[43;30m\]\$GIT_BRANCH \"
echo -en \"\[\e[33;49m\]\xee\x82\xb0\[\e[00m\] \"
@dundee
dundee / czech_vat_payer.py
Created August 16, 2017 11:21
Script for checking if subject is vat payer in CZ
from __future__ import print_function
import requests
from typing import Optional
ADIS_HOST = 'https://adisreg.mfcr.cz'
ADIS_URL = '/cgi-bin/adis/idph/int_dp_prij.cgi?id=1&pocet=1&fu=&OK=+Search+&ZPRAC=RDPHI1&dic='
RESPONSE_VAT_REGISTERED = u'Plátce'
RESPONSE_VAT_INDETIFIED_PERSON = u'Identifikovaná osoba'
@dundee
dundee / file.sh
Last active November 9, 2017 15:40
PKBUILD ironpython-git
# Maintainer: Michael Schubert <mschu.dev at gmail>
pkgname=ironpython-git
pkgver=r2315.ac72964d7
pkgrel=1
pkgdesc="Python implementation for the .NET framework"
arch=("any")
url="http://ironpython.net"
license=("Apache")
depends=('mono' 'msbuild-bin')
makedepends=('git')
@dundee
dundee / decorator_with_descriptor.py
Created June 12, 2017 11:07
Decorator for both functions and methods using descriptor
from functools import wraps
class DomainObject:
# nejaky domenovy objekt, ktery vyzaduje hodne parametru
def __init__(self, root, args, context, info):
pass
def process(self):
return 'OK'
@dundee
dundee / test.py
Created June 23, 2015 09:38
Dependency injection by using multiple inheritance
class Robot(object):
def move_forward():
print('Moving forward')
def move_backward():
print('Moving backward')
class CleaningRobot(Robot):
@dundee
dundee / test.py
Created May 5, 2015 10:46
My fail
log_file = os.path.join(
log_dir,
'deadlocks'
'{}.log'.format(datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S'))
)
@dundee
dundee / gist:831bdb68d30c80a0b126
Created December 20, 2014 12:29
Python descriptors and metaclass benchmark
import sys
from datetime import datetime
if sys.version_info[0] == 2:
range = xrange
class StockClassic(object):
@dundee
dundee / sublime-keymap
Created May 9, 2014 14:45
Sublime keys
[
{ "keys": ["ctrl+space"], "command": "goto_definition" },
{ "keys": ["f1"], "command": "goto_documentation" },
{ "keys": ["ctrl+shift+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+shift+down"], "command": "select_lines", "args": {"forward": true} },
{ "keys": ["insert"], "command": "select_lines" },
]