Skip to content

Instantly share code, notes, and snippets.

@polymorphm
polymorphm / test-thread-cost.py
Created February 9, 2014 18:18
script for testing how much cost of creating thread
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
import datetime
import threading
def test(n, use_thread=None):
if use_thread is None:
use_thread = True
@polymorphm
polymorphm / dns-ipv4-result.txt
Created February 2, 2014 13:12
DNS results on DomRu
$ host -v 2chru.net 8.8.8.8
Trying "2chru.net"
Using domain server:
Name: 8.8.8.8
Address: 8.8.8.8#53
Aliases:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6232
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
@polymorphm
polymorphm / test-of-DPI.py
Created February 1, 2014 21:03
test of DPI (Deep Packet Inspection)
# -*- mode: python; coding: utf-8 -*-
assert str is not bytes
# DPI -- Deep Packet Inspection
def test_dpi(host, data):
import socket
ss = socket.create_connection((host, 80), timeout=10.0)
s = ss.makefile(mode='rwb')
@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
# -*- 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 / smartctl.txt
Created November 30, 2013 09:11
Intel SSD 335 Series
[root@localhost ~]# smartctl -a /dev/sda
smartctl 6.2 2013-07-26 r3841 [x86_64-linux-3.12.1-3-ARCH] (local build)
Copyright (C) 2002-13, Bruce Allen, Christian Franke, www.smartmontools.org
=== START OF INFORMATION SECTION ===
Model Family: Intel 330/335 Series SSDs
Device Model: INTEL SSDSC2CT240A4
Serial Number: CVKI3161041Q240DGN
LU WWN Device Id: 5 5cd2e4 0000bbc69
Firmware Version: 335u
#!/usr/bin/env python3
# -*- mode: python; coding: utf-8 -*-
assert str is not bytes
import sys, os, os.path
if __name__ == '__main__':
for src_path in sys.argv[1:]:
src_name, src_ext = os.path.splitext(src_path)
@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[]) {
@polymorphm
polymorphm / et_find.py
Last active December 21, 2015 07:28
advanced search in ElementTree
# -*- mode: python; coding: utf-8 -*-
#
# Copyright 2013 Andrej Antonov <[email protected]>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
#!/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