This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A quick and dirty hack to caluclate 32-bit fixed-point log2 at compile-time | |
// for defining constants and doing template metaprogramming where a fractional | |
// result is required. | |
// Apart from the static assertion, this code can be used even in C++98. | |
// | |
// NOTE: The first argument to `FixedPointLog2` should already be in fixed-point | |
// form (e.g. in order to calculate the log2 of 3 with the result in the | |
// form s15.16, you should use `FixedPointLog2<(3 << 16), 16>`. | |
#include <stddef.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A dirty hack to generate the AES S-Box at compile-time. | |
// Not optimised. Please do not use. | |
// Requires C++14 for std::integer_sequence | |
#include <cstddef> | |
#include <cstdint> | |
#include <type_traits> | |
#include <utility> | |
template<std::uintmax_t Value> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import struct | |
import itertools | |
from base64 import b64encode | |
from retrie.trie import Trie | |
def commonise_group(pat): | |
patr = list(sorted(''.join(reversed(s)) for s in pat)) | |
common = [patr[0]] | |
pat_map = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Originally by Tyler Rhodes at https://gist.github.com/trhodeos/5a20b438480c880f7e15f08987bd9c0f | |
# Was broken in later fire versions due to unwrapping of decorated | |
# functions by fire, which ignores the signature of the wrapper and | |
# just doesn't pass the needed parameters, so I reimplemented this | |
# without functools.wraps() and added a bit more validation. | |
# Unfortunately this solution adds unneeded things to the help output | |
# due to the added varargs and kwargs, but there's no way around this | |
# that I know of. | |
import fire |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A simple and correct LG KDZ Android image extractor, because I got fed up | |
# with the partially working one from kdztools. | |
# | |
# Copyright (c) 2021 Isaac Garzon | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef _WIN32 | |
# include <Windows.h> | |
typedef HANDLE out_handle_t; | |
#else | |
# include <unistd.h> | |
typedef int out_handle_t; | |
#endif | |
#ifdef _MSC_VER | |
# include <string.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <unistd.h> | |
#define CACHELINE 64 | |
#define ALIGNED_BUF 65536 | |
#define FIZZ "Fizz" | |
#define BUZZ "Buzz" | |
#define DELIM " " | |
typedef struct { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <unistd.h> | |
#define CACHELINE 64 | |
#define ALIGNED_BUF 65536 | |
#define DELIM " " | |
typedef struct { | |
unsigned short offset; | |
char data[CACHELINE - sizeof(unsigned short)]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string.h> | |
#include <unistd.h> | |
#define ALIGNED_BUF 65536 | |
#define DELIM ' ' | |
#define MAX_DIGITS 20 /* 64-bit */ | |
typedef unsigned int fizz_t; | |
__attribute__((always_inline)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
enum | |
{ | |
FIZZ = 1, | |
BUZZ = 2 | |
}; | |
static int get_natural(const char *val, unsigned int *out) | |
{ |
NewerOlder