Skip to content

Instantly share code, notes, and snippets.

View nmoinvaz's full-sized avatar

Nathan Moinvaziri nmoinvaz

  • Phoenix, United States
View GitHub Profile
@nmoinvaz
nmoinvaz / adler32_benchmark.cc
Last active December 1, 2021 18:55
adler32_benchmark_pr_1053
/*
cmake_minimum_required(VERSION 3.17)
cmake_policy(SET CMP0091 NEW)
project(adler32_benchmark CXX)
set(BENCHMARK_ENABLE_GTEST_TESTS OFF)
add_executable(adler32_benchmark)
add_subdirectory(benchmark)
target_sources(adler32_benchmark PRIVATE adler32_benchmark.cc)
@nmoinvaz
nmoinvaz / crc32_benchmark.cc
Last active July 7, 2021 04:23
crc32_benchmark.cc
/*
cmake_minimum_required(VERSION 3.17)
cmake_policy(SET CMP0091 NEW)
include(FetchContent)
project(crc32_benchmark CXX)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
@nmoinvaz
nmoinvaz / cursortable.js
Last active November 10, 2023 22:33
Antd Cursor Paginated Table Component
import React, { useEffect, useState } from "react";
import { Table, Button, Space, Row, Col } from "antd";
import { LeftOutlined, RightOutlined } from "@ant-design/icons";
const CursorPagination = ({ startKey, lastEvaluatedKey, onChange, size }) => {
/* Use stack to keep track of which evaluated keys have been previously seen */
const [ prevEvaluatedKeys, setPrevEvaluatedKeys ] = useState([]);
/* Keep track of the current evaluated key */
const [ currentEvaluatedKey, setCurrentEvaluatedKey ] = useState(null);
@nmoinvaz
nmoinvaz / bi_reverse.c
Last active May 5, 2021 01:55
zlib-ng bi-reverse table
#include <stdio.h>
#include <cstdlib>
#include <map>
unsigned bi_reverse(unsigned code, int len) {
/* code: the value to invert */
/* len: its bit length */
unsigned long res = 0;
do {
import sys
if sys.version_info.major < 3:
print('Python 3 or higher is required to run this script')
exit(1)
import os
import argparse
import codecs
import pprint
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": ["checksum_fuzzer", ".git", ".gitattributes", ".github", ".gitignore", ".not-used", ".shellcheckrc", "CMakeFiles", "CMakeLists.txt", "FAQ.zlib", "INDEX.md", "LICENSE.md", "Makefile.in", "README.md", "adler32.c", "adler32_p.h", "arch", "chunkset.c", "chunkset_tpl.h", "cmake", "compare258.c", "compress.c", "configure", "crc32.c", "crc32_p.h", "crc32_tbl.h", "deflate.c", "deflate.h", "deflate_fast.c", "deflate_medium.c", "deflate_p.h", "deflate_quick.c", "deflate_slow.c", "doc", "fallback_builtins.h", "functable.c", "functable.h", "gzguts.h", "gzlib.c", "gzread.c", "gzwrite.c", "infback.c", "inffast.c", "inffast.h", "inffixed_tbl.h", "inflate.c", "inflate.h", "inflate_p.h", "inftrees.c", "inftrees.h", "insert_string.c", "insert_string_tpl.h", "match_tpl.h", "test", "tools", "tr
@nmoinvaz
nmoinvaz / hashtable_mask.txt
Last active July 3, 2020 16:34
Zlib-ng hash table mask results
Results in the comments..
@nmoinvaz
nmoinvaz / switchlevels_burn.py
Last active May 27, 2020 14:31
Zlib-ng switchlevels python burn test script
import os
import random
import argparse
parser = argparse.ArgumentParser(description='Switchlevel burn script')
parser.add_argument('--bin_dir', help='Binaries directory', default='.\\Debug\\')
parser.add_argument('--test_file', help='Test file to compress', default='test/data/lcet10.txt')
args, unknown = parser.parse_known_args()
for y in range(0, 100000):
@nmoinvaz
nmoinvaz / deflateparams.c
Last active May 25, 2020 13:45
Zlib-ng deflate parameter testing tool
/* deflateparams.c -- test deflate under specific conditions
* Copyright (C) 2020 Nathan Moinvaziri
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
add_executable(deflateparams test/deflateparams.c)
configure_test_executable(deflateparams)
target_link_libraries(deflateparams zlib)
*/
@nmoinvaz
nmoinvaz / longest_match_benchmark.cc
Last active May 25, 2020 13:44
Google benchmark for testing longest_match improvements
/* longest_match_benchmark.cc -- test longest_match timing
* Copyright (C) 2020 Nathan Moinvaziri
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
cmake . -A Win32 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL -DWITH_GZFILEOP=ON -DBUILD_SHARED_LIBS=OFF
cmake_minimum_required(VERSION 3.17)
cmake_policy(SET CMP0091 NEW)