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
#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;
#include <cstddef>
#include <iostream>
#include <stdexcept>
#include <tuple>
#include <type_traits>
#include <utility>
namespace op {
@orlp
orlp / excavate.lua
Last active October 13, 2015 19:38
Excavation program for turtles in minecraft.
-- run by calling: f=fs.open("/startup", "w");f.write(http.get("https://gist.github.com/raw/4246007").readAll());f.close();dofile("/startup")
-- orientation: 0 = N, 1 = E, 2 = S, 3 = W
function save_state()
f = fs.open("/excavate_state", "w")
f.write("state = ")
f.write(textutils.serialize(state))
f.close()
@orlp
orlp / build.txt
Last active December 16, 2015 20:39
New build.
CPU: Intel Core i5 2500K - 190.00
GPU: GTX 560Ti 2g Twin Frozr - 125.00
PSU: Corsair Builder Series CX430 - 41.90
Motherboard: MSI Z68A-G43 (G3) - 65.00
RAM: Crucial Ballistix BLS2CP4G3D1609DS1S00CEU - 54.90
Case: Corsair Carbide 300R - 64.90
Cooler: Gelid Tranquillo Rev.2 - 27.90
Hard Disk: Seagate Barracuda ST1000DM003 - 56.50
Monitor: Dell UltraSharp U2312HM - 189.90
SSD: Crucial M4 128gb - 100.90
@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
@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 / 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 / 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 / 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]]...