Skip to content

Instantly share code, notes, and snippets.

@herrfz
herrfz / roman.py
Last active January 20, 2024 12:03
Convert to roman numeral
from itertools import repeat
def to_roman(n):
return (''.join(repeat('I', n))
.replace('IIIII', 'V')
.replace('VV', 'X')
.replace('XXXXX', 'L')
.replace('LL', 'C')
.replace('CCCCC', 'D')
.replace('DD', 'M')
import socket
addr_info = socket.getaddrinfo("towel.blinkenlights.nl", 23)
addr = addr_info[0][-1]
s = socket.socket()
s.connect(addr)
while True:
data = s.recv(500)
print(str(data, 'utf8'), end='')
# Python 3
def reverse_dotted_ipv6(address):
ADDR_HEX_LEN = 32
GROUP_LEN = 4
try:
splitted = address.replace('::', ':0000:').split(':') # check for grouping format
if len([x for x in splitted if len(x) != GROUP_LEN]) != 0:
return '(╯°□°)╯︵ ┻━┻)'
bytearray.fromhex(address.replace(':', '')) # check for non-hex character
@herrfz
herrfz / graphapi
Created May 27, 2014 18:48
toying around with graph api
{
"metadata": {
"name": "",
"signature": "sha256:05422648a49f22daa0f624f940cf7c2a837c449095c78bce172b4a5073a0084c"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [

Keybase proof

I hereby claim:

  • I am herrfz on github.
  • I am herrfz (https://keybase.io/herrfz) on keybase.
  • I have a public key whose fingerprint is 76B8 3730 D93D 983E 887F 109E 9E04 2CAA 0416 640D

To claim this, I am signing this object:

@herrfz
herrfz / nMAP_tests
Created March 20, 2014 14:07
nMAP tests
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
from sklearn.base import BaseEstimator, TransformerMixin
class Transformer(BaseEstimator, TransformerMixin):
def __init__(self, fn):
self.fn = fn
def fit(self, X, y):
return self
def transform(self, X):
@herrfz
herrfz / Reuters.py
Last active October 18, 2021 19:27
Reuters-21578 keyword extraction
# Reuters-21578 dataset downloader and parser
#
# Author: Eustache Diemert <[email protected]>
# http://scikit-learn.org/stable/auto_examples/applications/plot_out_of_core_classification.html
#
# Modified by @herrfz, get pandas DataFrame from the orig SGML
# License: BSD 3 clause
from __future__ import print_function
@herrfz
herrfz / AES.c
Created September 18, 2013 09:16 — forked from bricef/AES.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* MCrypt API available online:
* http://linux.die.net/man/3/mcrypt
*/
#include <mcrypt.h>
@herrfz
herrfz / DMS tester
Created July 16, 2013 08:28
DMS test case example
package com.triagnosys.dms.tester;
import one_thousand_things;
public class TestCases extends TestCase {
private static final String SOME_CONSTANTS;
public void testGetSession() throws AxisFault {
System.out.println("Testing DMS getSession");