Skip to content

Instantly share code, notes, and snippets.

View roolebo's full-sized avatar

Roman Bolshakov roolebo

View GitHub Profile
@roolebo
roolebo / getnameinfo.c
Created August 8, 2019 13:14
getnameinfo for IPv6 address on macOS
/*
* This shows somewhat special behaviour when getnameinfo on macOS converts
* an IPv6 to a kind of IPv4-translated address.
*
* It turns IPv6 address "::ffff" into "::0.0.255.255"
*/
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
@roolebo
roolebo / leak.py
Created May 29, 2016 10:36
Python 3.4-3.5 pipe leak in multiprocessing.Process
import unittest
from multiprocessing import Process
import time
import os
import fcntl
def count_leaks(process_count):
def p_start(i):
@roolebo
roolebo / beautiful-soup-assertion-rewriting.py
Last active August 29, 2015 14:15
assertion rewriting fails on bs4.element.Tag
# vim: set fileencoding=utf-8 :
# related: https://bitbucket.org/hpk42/pytest/issue/453/assertion-rewriting-fails-with-object
#pip install beautifulsoup4
from bs4 import BeautifulSoup
def test_unicode():
soup = BeautifulSoup('<b class="boldest">Б - Бага</b>')
assert isinstance(soup.b, unicode)
@roolebo
roolebo / des.tcl
Created October 11, 2010 13:31
DES encryption on Tcl
#initial permutation
set IP {
58 50 42 34 26 18 10 2
60 52 44 36 28 20 12 4
62 54 46 38 30 22 14 6
64 56 48 40 32 24 16 8
57 49 41 33 25 17 9 1
59 51 43 35 27 19 11 3
61 53 45 37 29 21 13 5
63 55 47 39 31 23 15 7