Skip to content

Instantly share code, notes, and snippets.

View orlp's full-sized avatar
⚠️
This user's social credit score is unknown.

Orson Peters orlp

⚠️
This user's social credit score is unknown.
  • Leiden, Netherlands
View GitHub Profile
@orlp
orlp / genfilter.py
Last active February 7, 2017 20:30
# Standard, Hardcore, tmpstandard, tmphardcore
league = "tmpstandard"
categories = [
"DivinationCards",
"Essence",
"UniqueMap",
"UniqueFlask",
"UniqueWeapon",
"UniqueArmour",
"UniqueMap",
@orlp
orlp / peg.py
Last active July 3, 2018 02:10
PEG parser in Python.
from __future__ import unicode_literals
import sys
# We only use unicode in our parser, except for __repr__, which must return str.
if sys.version_info.major == 2:
repr_str = lambda s: s.encode("utf-8")
str = unicode
else:
repr_str = lambda s: s
@orlp
orlp / configure.py
Last active October 15, 2022 21:39
A template for a ninja configuration file.
import os
import sys
import fnmatch
__doc__ = """Build configurator.
Usage:
configure.py [options] [-D var[=val]]...
@orlp
orlp / ascii_ctype.h
Last active June 26, 2018 11:16
An ASCII only ctype.h implementation (C11/C++11 char32_t).
#ifndef ASCII_CTYPE_H
#define ASCII_CTYPE_H
#define ASCIIRANGE(c, start, len) (char32_t((c) - (start)) < char32_t(len))
inline bool aislower(char32_t c) { return ASCIIRANGE(c, 0x61, 26); }
inline bool aisupper(char32_t c) { return ASCIIRANGE(c, 0x41, 26); }
inline bool aisdigit(char32_t c) { return ASCIIRANGE(c, 0x30, 10); }
inline bool aisbdigit(char32_t c) { return ASCIIRANGE(c, 0x30, 2); }
inline bool aisodigit(char32_t c) { return ASCIIRANGE(c, 0x30, 8); }
inline bool aisxdigit(char32_t c) { return ASCIIRANGE(c | 32, 0x61, 6) || aisdigit(c); }
@orlp
orlp / fast_sin.c
Last active May 2, 2017 19:03
Fast sin implementation for IEEE754 doubles.
inline double fast_sin(double x) {
// Polynomial constants generated with sollya.
// fpminimax(sin(x), [|1,3,5,7|], [|D...|], [-pi/2;pi/2]);
// Both relative and absolute error is 9.39e-7.
const double magicround = 6755399441055744.0;
const double negpi = -3.14159265358979323846264338327950288;
const double invpi = 0.31830988618379067153776752674502872;
const double a = -0.00018488140186756154724131984146140;
const double b = 0.00831189979755905285208061883395203;
const double c = -0.16665554092439083255783316417364403;
@orlp
orlp / chacha.h
Last active April 25, 2024 12:36
C++11 ChaCha implementation.
/*
Copyright (c) 2024 Orson Peters <orsonpeters@gmail.com>
This software is provided 'as-is', without any express or implied warranty. In no event will the
authors be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose, including commercial
applications, and to alter it and redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim that you wrote the
#include <cstddef>
#include <iostream>
#include <stdexcept>
#include <tuple>
#include <type_traits>
#include <utility>
namespace op {
#include <cstddef>
template<class T, T... I>
struct integer_sequence {
using value_type = T;
static constexpr std::size_t size() noexcept { return sizeof...(I); }
};
namespace detail {
template<class, class> struct Combine;
@orlp
orlp / gist:7276926
Last active December 27, 2015 05:49
CPU: Intel Core i5 4670K - 194.90
SSD: Crucial 2.5" M500 240GB - 144.90
PSU: Seasonic M12II 520W - 59.00
Hard Disk: Seagate Barracuda 7200.14 ST2000DM001, 2TB - 74.90
Monitor: Dell UltraSharp U2312HM - 184.00
GPU: Sapphire R9 280X 3GB GDDR5 OC DUAL-X - 258.90
Case: Corsair Carbide 300R - 64.90
Cooler: HR-02 Macho - 44.90
Motherboard: Asus Z87-A - 123.90
RAM: Crucial Ballistix Sport BLS2CP8G3D1609DS1S00CEU - 134.90