Skip to content

Instantly share code, notes, and snippets.

View dpiponi's full-sized avatar
🧱
In material form

Dan Piponi dpiponi

🧱
In material form
View GitHub Profile
@dpiponi
dpiponi / main.cpp
Created October 22, 2024 19:51
WFT? Where's my code
//aasasddasdas
@dpiponi
dpiponi / main.cpp
Created April 11, 2024 16:46
De/serialization in C++ (not suitable when typeid not consistent)
#include <iostream>
#include <sstream>
#include <map>
template<typename T>
void ReadAndConsume(std::istringstream& s)
{
T t;
s >> t;
std::cout << t << ' ';
@dpiponi
dpiponi / tribonacci.cpp
Created April 3, 2024 17:31
Print the tribonacci numbers
#include <iostream>
// See https://arxiv.org/abs/2404.01483
long p(long x, long y, long z)
{
return x*x*x + 2*x*x*y + x*x*z + 2*x*y*y - 2*x*y*z - x*z*z + 2*y*y*y - 2*y*z*z + z*z*z;
}
const int N = 505;
data Weird = Weird { a0 :: Integer
, a1 :: Integer
, a2 :: Integer
, a3 :: Integer
, a4 :: Integer
, a5 :: Integer
, a6 :: Integer
} deriving Show
instance Num Weird where
@dpiponi
dpiponi / weird.cpp
Created March 7, 2024 21:28
solving that 2,3,7 puzzle efficiently
#include <iostream>
class Weird {
public:
float a0, a1, a2, a3, a4, a5, a6;
Weird(float b0, float b1, float b2, float b3, float b4, float b5, float b6)
: a0(b0), a1(b1), a2(b2), a3(b3), a4(b4), a5(b5), a6(b6) {}
Weird operator*(const Weird &other) const {
return Weird(
@dpiponi
dpiponi / decay.cpp
Created March 6, 2024 00:56
My own implementation of decay, just to be sure it does what I think
#include <type_traits>
template<typename T, typename U>
constexpr bool is_decay_equ = std::is_same_v<std::decay_t<T>, U>;
template<typename T>
struct MyDecay
{
static auto Helper(T x)
{
#
METHOD: TABLE
ENCODE: Unicode
PROMPT: TeX 1.1
VERSION: 1.1
DELIMITER: ,
MAXCODE: 6
VALIDINPUTKEY: ^,.?!:;"'/\()[]{}<>$%&@*01234567890123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
TERMINPUTKEY:
BEGINCHARACTER
@dpiponi
dpiponi / main.cpp
Last active November 5, 2023 21:41
Min phase filter computation using QR decomposition
#include <cmath>
#include <iostream>
#include <numeric>
#include <valarray>
#include <vector>
// Motivated by
// Computing the Minimum-Phase filter using the QL-Factorization
// Hansen, Morten; Christensen, Lars P.b.; Winther, Ole
// https://backend.orbit.dtu.dk/ws/portalfiles/portal/5161145/Hansen.pdf
@dpiponi
dpiponi / infill.glsl
Created May 18, 2022 03:39
Walk-on-spheres
// See https://www.cs.cmu.edu/~kmcrane/Projects/MonteCarloGeometryProcessing/
// Random numbers using code at
// https://stackoverflow.com/a/17479300
// A single iteration of Bob Jenkins' One-At-A-Time hashing algorithm.
uint hash( uint x ) {
x += ( x << 10u );
x ^= ( x >> 6u );
x += ( x << 3u );
(** User Mathematica initialization file **)
(** See https://reference.wolfram.com/language/tutorial/ConfigurationFiles.html for info on instaling this file **)
(** Display graphics inline in iTerm2. I don't know an easy way to test if we're running in iTerm2 without looking at the process table. **)
imgcat[image_Graphics]:=(
WriteString[$Output, "\033]1337;File=inline=1:"<>ExportString[ExportString[image,"PNG"],"Base64"]<>"\007"];
Null
)