Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View degski's full-sized avatar
💭
stop watching us

degski

💭
stop watching us
View GitHub Profile
@degski
degski / seed_seq_fe.hpp
Created July 2, 2018 04:13
seed_seq_fe
/* boost random/seed_seq_fe.hpp header file
*
* Copyright Melissa E. O'Neill 2015
* Copyright degski 2017
* Distributed under the Boost Software License, Version 1.0. (See
* accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* See http://www.boost.org for most recent version including documentation.
*
@degski
degski / statistics.hpp
Created July 20, 2018 10:11
The main statistics of a vector/array of data
// MIT License
//
// Copyright (c) 2018 degski
//
// 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
@degski
degski / CentripetalCatmullRom.cpp
Last active October 2, 2018 14:10
Centripetal Catmull-Rom curves
#include <cmath>
#include <iostream>
#include <utility>
#include <SFML/Graphics.hpp>
// https://stackoverflow.com/questions/9489736/catmull-rom-curve-with-no-cusps-and-no-self-intersections/23980479#23980479
@degski
degski / fab.hpp
Created February 5, 2019 15:20
floats as bits print structure
struct float_as_bits {
float_as_bits ( const float & v_ ) : value { v_ } { };
float_as_bits ( float && v_ ) : value { std::move ( v_ ) } { };
template<typename Stream>
[[ maybe_unused ]] friend Stream & operator << ( Stream & out_, const float_as_bits & v_ ) noexcept {
std::uint32_t v;
std::memcpy ( &v, &v_.value, 4 );
// MIT License
//
// Copyright (c) 2019 degski
//
// 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
@degski
degski / lehmer.hpp
Created July 9, 2018 11:42
re-write of lehmer.hpp (https://gist.github.com/imneme/aeae7628565f15fb3fef54be8533e39c) as a workaround for an ICE in Clang/LLVM
#ifndef LEHMER_HPP_INCLUDED
#define LEHMER_HPP_INCLUDED 1
/*
* A C++ implementation of fast, 128-bit, Lehmer-style PRNGs
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Melissa E. O'Neill
* Copyright (c) 2018 degski
@degski
degski / sort.hpp
Last active March 17, 2019 10:23
constexpr comb_sort
template<typename Array>
constexpr void comb_sort_impl ( Array & array_ ) noexcept {
using size_type = typename Array::size_type;
size_type gap = array_.size ( );
bool swapped = false;
while ( ( gap > size_type { 1 } ) or swapped ) {
if ( gap > size_type { 1 } ) {
gap = static_cast<size_type> ( gap / 1.247330950103979 );
}
swapped = false;
@degski
degski / _clang-format
Last active April 8, 2019 03:41
Clang Format for C++
---
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: 0
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Right
AlignOperands: true
AlignTrailingComments: true
AllowShortCaseLabelsOnASingleLine: true
@degski
degski / main.cpp
Created April 24, 2019 06:23
LZ4 linear search versus binary search
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <array>
#include <random>
#include <frozen/map.h>
#include <plf/plf_nanotimer.h>
@degski
degski / main-469827.cpp
Created May 6, 2019 13:14
Clang bug 41745
This file has been truncated, but you can view the full file.
# 1 "<built-in>"
# 1 "main.cpp"
#if 0 /* expanded by -frewrite-includes */
#include <cassert>
#endif /* expanded by -frewrite-includes */
# 2 "main.cpp"
# 1 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.16.27023\\include\\cassert" 1 3
// cassert standard header
// NOTE: no include guard