Skip to content

Instantly share code, notes, and snippets.

View Twilight-Dream-Of-Magic's full-sized avatar

Twilight-Dream-Of-Magical Twilight-Dream-Of-Magic

View GitHub Profile
@ThePhD
ThePhD / tracking_allocator.hpp
Last active February 21, 2022 17:45
A tracking allocator for mostly testing purposes.
#include <memory>
#include <cstddef>
#include <type_traits>
template<typename Allocator>
class tracking_allocator
{
private:
template <typename>
friend class tracking_allocator;
@MasterAler
MasterAler / serialization.hpp
Last active February 28, 2022 22:22
simple custom serialization example
#pragma once
#include <iostream>
#include <string>
#include <list>
#include <iterator>
#include <type_traits>
#include <algorithm>
/* This is a small & simple example
@imneme
imneme / splitmix.hpp
Created July 4, 2018 04:24
A C++ implementation of SplitMix
#ifndef SPLITMIX_HPP_INCLUDED
#define SPLITMIX_HPP_INCLUDED 1
/*
* A C++ implementation of SplitMix
* Original design by Guy L. Steele, Jr., Doug Lea and Christine H. Flood
* Described in _Fast splittable pseudorandom number generators_
* http://dx.doi.org/10.1145/2714064.2660195 and implemented in
* Java 8 as SplittableRandom
* Based on code from the original paper, with revisions based on changes
/**
* @file memory_tracking.cpp
* Implements simple memory tracking for use in C++ applications. Define
* TRACK_MEMORY to enable during debug and unit testing, and undef for
* production.
* Version 1.01
*
* Copyright (c) Josh Carter <josh@multipart-mixed.com>, 2006
* All rights reserved.
*
@jtbr
jtbr / endianness.h
Last active June 7, 2024 21:07
cross-platform / cross-compiler standalone endianness conversion
/**
* @file endianness.h
* @brief Convert Endianness of shorts, longs, long longs, regardless of architecture/OS
*
* Defines (without pulling in platform-specific network include headers):
* bswap16, bswap32, bswap64, ntoh16, hton16, ntoh32 hton32, ntoh64, hton64
*
* Should support linux / macos / solaris / windows.
* Supports GCC (on any platform, including embedded), MSVC2015, and clang,
* and should support intel, solaris, and ibm compilers as well.
@mimoo
mimoo / erase_from_memory.h
Last active April 8, 2024 21:17
Include this file to get the `erase_from_memory` function that zeros memory. See https://www.cryptologie.net/article/419/zeroing-memory-compiler-optimizations-and-memset_s/
#ifndef __ERASE_FROM_MEMORY_H__
#define __ERASE_FROM_MEMORY_H__ 1
#define __STDC_WANT_LIB_EXT1__ 1
#include <stdlib.h>
#include <string.h>
void *erase_from_memory(void *pointer, size_t size_data, size_t size_to_remove) {
#ifdef __STDC_LIB_EXT1__
memset_s(pointer, size_data, 0, size_to_remove);
@wavezhang
wavezhang / java_download.sh
Last active June 26, 2024 11:54
download java from oracle without login
wget -c --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/12.0.2+10/e482c34c86bd4bf8b56c0b35558996b9/jdk-12.0.2_linux-x64_bin.tar.gz
@ecnelises
ecnelises / Serialize.hpp
Created September 9, 2016 05:09
简易的C++二进制序列化类,模仿boost::serialization
// Serialize.hpp
// 简易的C++二进制序列化类,模仿boost::serialization
// 邱超凡 2016.9.9
#ifndef CPP_SERIALIZE_HPP
#define CPP_SERIALIZE_HPP
#include <fstream>
#include <algorithm>
#include <type_traits>
@imneme
imneme / randutils.hpp
Last active March 28, 2024 20:43
Addresses common issues with C++11 random number generation; makes good seeding easier, and makes using RNGs easy while retaining all the power.
/*
* Random-Number Utilities (randutil)
* Addresses common issues with C++11 random number generation.
* Makes good seeding easier, and makes using RNGs easy while retaining
* all the power.
*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Melissa E. O'Neill
*