Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
assert str is not bytes
import sys
import csv
def main():
for arg in sys.argv[1:]:
#!/usr/bin/env python2
# -*- mode: python; coding: utf-8 -*-
from __future__ import absolute_import, print_function
assert unicode is not str
assert str is bytes
import sys, datetime
@polymorphm
polymorphm / test-py.cpp
Last active July 21, 2021 19:46
test (hello world) python-c-api
// -*- mode: cpp; coding: utf-8 -*-
//
// $ g++ -pedantic -std=c++11 -o test-py test-py.cpp $(pkg-config --cflags --libs python3)
//
#include <clocale>
#include <cstdlib>
#include <Python.h>
int main(int argc, char *argv[]) {
# -*- mode: sh; coding: utf-8 -*-
GOODZONE_FABRIC_WATERMARK_IMG=/home/regular-user/work/goodzone-fabric-convert/data/watermark.png
goodzone_fabric_convert_ico () {
mogrify -resize 160x160 "$@"
}
goodzone_fabric_convert_watermark () {
composite -compose atop -gravity center "$GOODZONE_FABRIC_WATERMARK_IMG" "$1" "$1"
@polymorphm
polymorphm / ipv6down.sh
Last active September 5, 2023 02:22
some config files for IPv6 (DHCPv6-PD over PPPoE)
#!/usr/bin/bash
#
# it is file -- /etc/ppp/ipv6-down.d/99-custom-internet.sh
#
if [ -z "$IFNAME" ] || [ "$LINKNAME" != "domru" ]
then
true
exit
@polymorphm
polymorphm / wsgi.py
Last active August 29, 2015 14:19
WSGI router (by host) example
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
assert str is not bytes
import my_example_1_wsgi as _my_example_1_wsgi
import my_example_2_wsgi as _my_example_2_wsgi
import my_example_3_wsgi as _my_example_3_wsgi
_application_by_host_dict = {
@polymorphm
polymorphm / data-find-and-replace.py
Last active August 29, 2015 14:19
find some text words in files and replace it to other words
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
assert str is not bytes
import sys
import os, os.path
import csv
import itertools
import random
#!/usr/bin/python
# -*- mode: python; coding: utf-8 -*-
import sys
import os, os.path
import json
def main():
# the path to cloned directory https://github.com/hyperboria/peers
peer_dir_path = sys.argv[1]
@polymorphm
polymorphm / bubble-lab.c
Last active November 6, 2018 17:36
simple bubble sorting of vectors (by their length). just for test
// to compile:
// gcc -Wall -Wextra -O3 -funsafe-math-optimizations -o bubble-lab bubble-lab.c
// or
// gcc -Wall -Wextra -O3 -funsafe-math-optimizations -DCANNOT_RANDOM -o bubble-lab bubble-lab.c
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifndef CANNOT_RANDOM
// gcc -Wall -Wextra -o hrenov-kompilator hrenov-kompilator.c
// or: gcc -Wall -Wextra -O3 -o hrenov-kompilator hrenov-kompilator.c
// or: clang -Wall -Wextra -o hrenov-kompilator hrenov-kompilator.c
// or: clang -Wall -Wextra -O3 -o hrenov-kompilator hrenov-kompilator.c
#include <stdlib.h>
#include <stdio.h>
int
main (int argc __attribute__ ((unused)),