Skip to content

Instantly share code, notes, and snippets.

public class Example2 {
static class NotFoundException extends Exception {}
static class Database {
java.util.Map<String,Integer> entries;
Database() {
entries = java.util.Collections.synchronizedMap(new java.util.HashMap<String,Integer>());
}
@vtermanis
vtermanis / threaded_lz4_full.py
Created February 24, 2020 17:40
Illustrates (de)compression of multiple lz4framed files/streams
#!/usr/bin/env python3
"""Illustrates (de)compression of multiple lz4framed files/streams"""
from time import monotonic
from sys import argv
from os import cpu_count
from io import BytesIO, SEEK_END
from concurrent.futures import ThreadPoolExecutor
@vtermanis
vtermanis / threaded_lz4.py
Created February 24, 2020 17:39
Illustrates (de)compression of multiple lz4framed files/streams without overhead of using the data
#!/usr/bin/env python3
"""Illustrates (de)compression of multiple lz4framed files/streams without overhead of using the data."""
from time import monotonic
from sys import argv
from os import cpu_count
from concurrent.futures import ThreadPoolExecutor
from lz4framed import Decompressor, Compressor, Lz4FramedNoDataError
@vtermanis
vtermanis / mysql_connector_leak_test.py
Created May 12, 2018 14:19
MySQL Connector/Python reference leak test script
#!/usr/bin/env python3
"""
Schema used:
SET sql_mode = 'NO_ENGINE_SUBSTITUTION,ANSI,MAXDB,TRADITIONAL,NO_AUTO_VALUE_ON_ZERO,ONLY_FULL_GROUP_BY';
CREATE DATABASE "leak_test";
USE "leak_test"
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) 2017 Iotic Labs Ltd. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://github.com/Iotic-Labs/py-lz4framed/blob/master/LICENSE
#!/usr/bin/env python3
from time import monotonic
from lz4framed import compress
SHORT_INPUT = b'abcdefghijklmnopqrstuvwxyz0123456789'
LONG_INPUT = SHORT_INPUT * (10**5)
# Input a byte shorter than below does not trigger slowdown (for new lz4, not r131)
# LONG_INPUT = LONG_INPUT[:65550]
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "lz4frame_static.h"
/******************************************************************************/
static LZ4F_preferences_t prefs_defaults = {{0, 0, 0, 0, 0, {0}}, 0, 0, {0}};