Skip to content

Instantly share code, notes, and snippets.

View DavidLudwig's full-sized avatar

David Ludwig DavidLudwig

View GitHub Profile
@mimshins
mimshins / linear-interpolation.ts
Created July 5, 2022 11:36
Lerp (linear interpolation), InverseLerp, and Remap functions in TypeScript
/**
* Linear interpolate on the scale given by `a` to `b`, using `t` as the point on that scale.
*/
export const lerp = (a: number, b: number, t: number) => a + t * (b - a);
/**
* Inverse Linar Interpolation, get the fraction between `a` and `b` on which `v` resides.
*/
export const inLerp = (a: number, b: number, v: number) => (v - a) / (b - a);
@stiano
stiano / Roslyn-CodeGeneration-WithDebugging-Tests.cs
Created August 21, 2018 19:29
Debugging Roslyn Generated Code
public class CodeGenTests
{
[NUnit.Framework.Test]
public void ShouldDebugSources()
{
var code =
@"namespace Debuggable
{
public class HelloWorld
{
@WangYihang
WangYihang / port-forwarding.py
Last active December 19, 2024 02:20
port forwarding via python socket
#!/usr/bin/env python3
# Tcp Port Forwarding (Reverse Proxy)
# Author : WangYihang <[email protected]>
'''
+-----------------------------+ +---------------------------------------------+ +--------------------------------+
| My Laptop (Alice) | | Intermediary Server (Bob) | | Internal Server (Carol) |
+-----------------------------+ +----------------------+----------------------+ +--------------------------------+
| $ ssh -p 1022 [email protected] |<------->| IF 1: 1.2.3.4 | IF 2: 192.168.1.1 |<------->| IF 1: 192.168.1.2 |
| [email protected]'s password: | +----------------------+----------------------+ +--------------------------------+