Skip to content

Instantly share code, notes, and snippets.

View ViktorStiskala's full-sized avatar

Viktor Stískala ViktorStiskala

View GitHub Profile
@ViktorStiskala
ViktorStiskala / gist:557567
Created August 30, 2010 15:33
Wondershaper script without LAN limitation
#!/bin/bash
# Wonder Shaper
# please read the README before filling out these values
#
# Speed/Rate syntax: tcng vs. tc
# source: http://www.faqs.org/docs/Linux-HOWTO/Traffic-Control-tcng-HTB-HOWTO.html
#
# tcng English tc
# ----------------------------------------------
# bps bit(s) per second bit
@ViktorStiskala
ViktorStiskala / .gitconfig
Created August 13, 2013 13:27
Pycharm as a default git difftool and git mergetool. Add the following to ~/.gitconfig
[diff]
tool = pycharm
[difftool "pycharm"]
cmd = /usr/local/bin/pycharm diff "$LOCAL" "$REMOTE" && echo "Press enter to continue..." && read
[merge]
tool = pycharm
keepBackup = false
[mergetool "pycharm"]
cmd = /usr/local/bin/pycharm merge "$LOCAL" "$REMOTE" "$BASE" "$MERGED"
def validate_account_number(value):
checksum = sum(int(value[i]) * (8-i) for i in range(7)) % 11
last_digit = int(value[-1])
if checksum in [0, 10]:
c = 1
elif checksum == 1:
c = 0
else:
c = 11 - checksum
def note_error(self, *msg):
if self.strict:
raise PermError(*msg)
# if lax mode, note error and continue
if not self.perm_error:
try:
raise PermError(*msg)
except PermError as x:
# FIXME: keep a list of errors for even friendlier diagnostics.
self.perm_error = x
#!/bin/bash
# CONFIGURATION
openssl_config_file=$(openssl ca 2>&1 | grep "Using configuration from" | sed 's/Using configuration from //g')
################################################################################
txtgrn='\e[0;32m'
txtred='\e[0;31m'
txtrst='\e[0m'
config_tempfile=$(mktemp --suffix openssl)
@ViktorStiskala
ViktorStiskala / random_crash.sh
Created January 22, 2014 10:47
Bash retry function with max_retries settings
#!/bin/bash
number=$RANDOM
let "number %= 10"
if [[ $number -gt 8 ]]
then
echo "Success"
exit 0
fi
@ViktorStiskala
ViktorStiskala / spayd.py
Created August 23, 2013 10:29
Convert account number to IBAN
def _convert_to_iban(self, account):
"""
Convert czech account number to IBAN
"""
acc = self.RE_ACCOUNT.match(account)
iban = 'CZ00{b}{ba:0>6}{a:0>10}'.format(
ba=acc.group('ba') or 0,
a=acc.group('a'),
b=acc.group('b'),
)
viktor@haree-nb /tmp/test/greenlet (git)-[master] % ./run-tests.py
running build_ext
Linking /tmp/test/greenlet/build/lib.linux-x86_64-2.7/greenlet.so to /tmp/test/greenlet/greenlet.so
python 2.7.4 (64 bit) using greenlet 0.4.0 from /tmp/test/greenlet/greenlet.so
test_dead_weakref (tests.test_weakref.WeakRefTests) ... ok
test_dealloc_weakref (tests.test_weakref.WeakRefTests) ... ok
test_inactive_weakref (tests.test_weakref.WeakRefTests) ... ok
test_version (tests.test_version.VersionTests) ... ok
test_exception_disables_tracing (tests.test_tracing.TracingTests) ... ok
test_greenlet_tracing (tests.test_tracing.TracingTests) ... ok
# 1 "greenlet.c"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "greenlet.c"
# 1 "greenlet.h" 1
.file "greenlet.c"
.text
.p2align 4,,15
.type green_is_gc, @function
green_is_gc:
.LFB142:
.cfi_startproc
cmpq $-1, 24(%rdi)
je .L3
xorl %eax, %eax