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')
@herrfz
herrfz / Reuters.py
Last active October 18, 2021 19:27
Reuters-21578 keyword extraction
# Reuters-21578 dataset downloader and parser
#
# Author: Eustache Diemert <eustache@diemert.fr>
# 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 / nMAP_tests
Created March 20, 2014 14:07
nMAP tests
{
"metadata": {
"name": ""
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
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='')
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 / 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");
@herrfz
herrfz / SOAP
Last active December 19, 2015 19:08
suds Python SOAP client
{
"metadata": {
"name": "soap_client"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@herrfz
herrfz / Clustering Example
Created February 10, 2013 23:24
Coursera Data Analysis -- in Python
{
"metadata": {
"name": "clustering_example"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@herrfz
herrfz / Dimension Reduction
Created February 10, 2013 14:25
Coursera Data Analysis -- in Python
{
"metadata": {
"name": "svd_pca"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{