Skip to content

Instantly share code, notes, and snippets.

View sinkingsugar's full-sized avatar

Giovanni Petrantoni sinkingsugar

View GitHub Profile
@sinkingsugar
sinkingsugar / ModifiedMarchingCubes.js
Created February 9, 2022 08:07 — forked from dwilliamson/ModifiedMarchingCubes.js
Transvoxel's Modified Marching Cubes Lookup Tables
//
// Lookup Tables for Transvoxel's Modified Marching Cubes
//
// Unlike the original paper (Marching Cubes: A High Resolution 3D Surface Construction Algorithm), these tables guarantee
// a closed mesh "whose connected components are continuous and free of holes."
//
// Rotations are prioritised over inversions so that 3 of the 6 cases containing ambiguous faces are never added. 3 extra
// cases are added as a post-process, overriding inverses through custom-build rotations to eliminate the rest.
//
// Uses the exact same co-ordinate system as https://gist.github.com/dwilliamson/c041e3454a713e58baf6e4f8e5fffecd
@sinkingsugar
sinkingsugar / WireGuard-site-to-site.md
Created January 6, 2021 10:27
Accessing a subnet that is behind a WireGuard client using a site-to-site setup

WireGuard Site-to-Site

Accessing a subnet that is behind a WireGuard client using a site-to-site setup

Problem Summary

We want to access a local subnet remotely, but it is behind a NAT firewall and we can't setup port forwarding. Outgoing connections work, but all incoming connections get DROPPED by the ISP's routing policy.

Solution Summary

use futures::future::Future;
use libp2p_core::identity;
use libp2p_core::transport::Transport;
use libp2p_core::upgrade::{self};
use libp2p_core::Multiaddr;
use libp2p_noise::{Keypair, NoiseConfig, X25519};
use libp2p_tcp::TcpConfig;
use tokio::{self, io};
fn main() {
@sinkingsugar
sinkingsugar / random.h
Created January 12, 2020 02:31 — forked from Leandros/random.h
C++ Pseudo Random Number Generators
/* Copyright (c) 2018 Arvid Gerstmann. */
/* This code is licensed under MIT license. */
#ifndef AG_RANDOM_H
#define AG_RANDOM_H
class splitmix
{
public:
using result_type = uint32_t;
static constexpr result_type (min)() { return 0; }
@sinkingsugar
sinkingsugar / Swizzles.h
Created January 12, 2020 02:31 — forked from NocturnDragon/Swizzles.h
Swizzles in Clang, GCC, and Visual c++
#include <stdio.h>
// #define CLANG_EXTENSION
// Clang compile with -O3
#define VS_EXTENSION
// https://godbolt.org/z/sVWrF4
// Clang compile with -O3 -fms-compatibility
// VS2017 compile with /O3
@sinkingsugar
sinkingsugar / gist:5a55308376423f2d8c69ea118f3186f6
Created December 11, 2018 19:06 — forked from chadhutchins/gist:1440602
Tarjan's strongly connected components algorithm in Javascript - followed pseudocode from http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm
window.onload = function() {
var v0 = new Vertex("0");
var v1 = new Vertex("1");
var v2 = new Vertex("2");
var v3 = new Vertex("3");
var v4 = new Vertex("4");
var v5 = new Vertex("5");
var v6 = new Vertex("6");
var v7 = new Vertex("7");
@sinkingsugar
sinkingsugar / ad-manifesto.md
Created November 11, 2018 05:18 — forked from rxwei/ad-manifesto.md
First-Class Automatic Differentiation in Swift: A Manifesto

First-Class Automatic Differentiation in Swift: A Manifesto

This document is written for both the machine learning community and the Swift programming language design community, with a strong focus on language design.

Table of Contents

@sinkingsugar
sinkingsugar / await.lua
Created October 15, 2015 06:22 — forked from ignacio/await.lua
await wrapper using coroutines (related to this gist: https://gist.github.com/creationix/5291866)
function await(continuation)
local coro = coroutine.running()
local result
local async
continuation(function(err, value)
if async == nil then
async = false
result = value
if err then error(err) end
return