Skip to content

Instantly share code, notes, and snippets.

Venryx / Fractional Indexing (David Greenspan).md
Last active May 10, 2024 03:37
List of various fractional-indexing schemes, along with language-specific implementations
Venryx /
Created December 21, 2022 21:41
Extensions of the `AsyncFn` trait for use with output-types and variable numbers of arguments (see:
use futures::Future;
pub trait AsyncFn_Args0<OutputType>: Fn() -> Self::Future {
type Future: Future<Output = OutputType>;
impl<OutputType, F, Fut> AsyncFn_Args0<OutputType> for F
where F: Fn() -> Fut, Fut: Future<Output = OutputType> {
type Future = Fut;
Venryx /
Created July 12, 2022 21:40 — forked from Kimundi/
Dynamic typing in Rust
use std::unstable::intrinsics::{TyDesc, get_tydesc, forget};
use std::util::Void;
use std::cast::transmute;
// TypeId
/// `TypeId` represents a globally unique identifier for a type
pub struct TypeId {
Venryx /
Last active April 18, 2022 05:35
Example of wrapper for RwLock that includes tracking of open lock-guards (for easy debugging of deadlocks)
use std::{sync::{Mutex, Arc}, ops::{Deref, DerefMut}};
use tokio::sync::{RwLock, RwLockReadGuard, RwLockWriteGuard};
/// Wrapper around RwLock, which:
/// 1) Requires that anyone who takes a lock-guard must supply their "name".
/// 2) Provides a way for anyone to get a list of "current lock-guard holders". (without having to take a lock-guard themselves)
pub struct RwLock_Tracked<T> {
l: RwLock<T>,
live_guards: Arc<Mutex<Vec<String>>>,
Venryx / coreos_prometheus->Tiltfile
Created August 14, 2021 13:27
coreos_prometheus, modified to work on Windows
# (C) Copyright 2020 Hewlett Packard Enterprise Development LP
def ToLPath(path):
return path.replace("\\", "/").replace("C:/", "/mnt/c/")
def ToWPath(path):
return path.replace("/", "\\").replace("\\mnt\\c\\", "C:\\")
def ListDir(path, recursive = False):
result = []
for file in listdir(ToWPath(path), recursive):
Venryx /
Created December 12, 2020 00:56 — forked from dimapaloskin/
Netflix seek
const videoPlayer = netflix
// Getting player id
const videoPlayer = videoPlayer
Venryx / GearVRInput.ts
Created December 10, 2020 11:30
GearVR controller connection code, using NodeJS's "noble" bluetooth-stack
import {Characteristic, Peripheral, Service} from "@abandonware/noble";
export class ControllerData {
accel: number[];
gyro: number[];
magX: number;
magY: number;
magZ: number;
Venryx / Example.kt
Last active February 17, 2020 23:07
Trigger SonicBomb shakes from your app
// Note: I'm not updating this anymore. For the latest version, see here:
val patterns = arrayOf(
"!WTRG0TRG0TRG0TRG;", // pulse
"!WPJ0FPV7S1J600;" // sos
// you can add your own patterns by mixing and matching the vibration components
// strength is between 0 and 100; pattern follows the format seen above
<!DOCTYPE html>
<meta charset="utf-8"/>
<script src=""></script>
<script src="./suite.js"></script>
<h1>Open the console to view the results</h1>
Venryx / Example.tsx
Last active February 9, 2023 22:36
Using "useImperativeHandle" in a React functional component, with automatic TypeScript typing
import {forwardRef, useImperativeHandle, ForwardRefExoticComponent, RefAttributes, Ref} from "react";
export type Handle<T> = T extends ForwardRefExoticComponent<RefAttributes<infer T2>> ? T2 : never;
export const Parent = (props: {})=> {
let childHandle: Handle<typeof Child>;
return (
<div onClick={()=>childHandle.SayHi()}>
<Child name="Bob" ref={c=>childHandle = c}/>