Skip to content

Instantly share code, notes, and snippets.

@Sgeo
Sgeo / gadts.rs
Last active July 14, 2023 12:14 — forked from mstewartgallus/gadts.rs
Gadts in Rust
/// This type is only every inhabited when S is nominally equivalent to T
#[derive(Debug)]
pub struct Is<S, T>(::std::marker::PhantomData<(*const S, *const T)>);
// Construct a proof of the fact that a type is nominally equivalent
// to itself.
pub fn is<T>() -> Is<T, T> { Is(::std::marker::PhantomData) }
// std::mem::transmute does not accept unsubstituted type parameters
// manual transmute as suggested by manual
r(t)^2 = x(t)^2 + y(t)^2 + z(t)^2
x(t+h) = x(t) + h * f(t) * -x(t) / r(t)^2
y(t+h) = y(t) + h * f(t) * -y(t) / r(t)^2
z(t+h) = z(t) + h * f(t) * -z(t) / r(t)^2
x(t+h) - x(t) = h * f(t) * -x(t)/r(t)^2
x'(t) = -f(t)x(t)/r(t)^2
#version 120
#if defined(VERTEX)
#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying
#version 120
#if defined(VERTEX)
#if __VERSION__ >= 130
#define COMPAT_VARYING out
#define COMPAT_ATTRIBUTE in
#define COMPAT_TEXTURE texture
#else
#define COMPAT_VARYING varying
@Sgeo
Sgeo / simuleyes_sbs_auto.glsl
Created February 18, 2023 09:03
Work in progress on DOSBox-X shader to conver SimulEyes -> SBS
#version 120
// Developed by tyrells
// Based on Marat Tanalin's algorithm: https://tanalin.com/en/articles/integer-scaling/
uniform vec2 rubyInputSize;
#if defined(VERTEX)
#if __VERSION__ >= 130
@Sgeo
Sgeo / opengl_vr_from_chatgpt.c
Created December 4, 2022 02:41
This code was written by ChatGPT
#include <Windows.h>
#include <MinHook.h>
#include <GL/gl.h>
#include <GL/glext.h>
#include <OVR_CAPI_GL.h>
// Declaration of the original function.
typedef void (__stdcall *glBegin_t)(GLenum);
glBegin_t original_glBegin;
effect focus<a>
ctl focus(a : a): a
fun vl-fst(f: a -> focus<r> b): (((a, c)) -> focus<r> (b, c))
fn(pair)
match pair
(a, c) -> (f(a), c)
fun vl-snd(f: a -> focus<r> b): (((c, a)) -> focus<r> (c, b))
fn(pair)
@Sgeo
Sgeo / mastervolume.js
Created January 5, 2021 21:41
Add a setVolume() function to affect all AudioContexts
// Based on https://github.com/notthetup/webaudio-volume-control/blob/master/mastervolume.js
(function() {
window.setVolume = function(){};
let origAudioContextConstructor = window.AudioContext;
window.AudioContext = function(options) {
let origAudioContext = new origAudioContextConstructor(options);
let masterGain = origAudioContext.createGain();
masterGain.connect(origAudioContext.destination);
let origSetVolume = window.setVolume;
@Sgeo
Sgeo / irixswextract.c
Last active August 11, 2020 01:55 — forked from camthesaxman/irixswextract.c
tool to extract IRIX software packages
#include <ctype.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
struct Archive
LEGAL DISCLAIMER
This product is meant for educational purposes only. Any resemblance to real persons, living or dead is purely coincidental. Void where prohibited. Some assembly required. Batteries not included. Contents may settle during shipment. Use only as directed. No other warranty expressed or implied. Do not use while operating a motor vehicle or heavy machinery. This is not an offer to sell securities. Apply only to affected area. May be too intense for some viewers. Do not stamp. For recreational use only. Do not disturb. All models over 18 years of age. No user-serviceable parts inside. Freshest if eaten before date on carton. Subject to change without notice. Times approximate. Simulated picture. Please remain seated until the ride has come to a complete stop. Breaking seal constitutes acceptance of agreement. For off-road use only. As seen on TV. One size fits all. Contains a substantial amount of non-tobacco ingredients. Colors may, in time, fade. Slippery when wet.
For office use only. Not