Skip to content

Instantly share code, notes, and snippets.

View eira-fransham's full-sized avatar

Eira Fransham eira-fransham

  • Berlin
View GitHub Profile
@eira-fransham
eira-fransham / opt-rc.rs
Last active April 27, 2026 10:08
A version of `Rc<T>` which doesn't allocate for ZSTs and has less memory overhead.
use std::{
any::Any,
cell::Cell,
mem,
num::NonZero,
ops::Deref,
ptr::NonNull,
};
struct OptRcInner<T: ?Sized> {
@eira-fransham
eira-fransham / drag-and-drop-research.md
Last active April 20, 2026 10:11
Drag-and-drop implementations across platforms

Drag-and-Drop Data Structures Across Platforms

The commonalities between drag-and-drop implementations across platforms are, roughly, the following:

  • Multiple file paths may be dragged at once
  • Events are received periodically by the target application while a drag operation is hovering over it
  • The mouse position is provided along with the drag events during hover and on drop
  • The drag data can be inspected during the drag operation, not just once the drop is executed
  • The source provides a set of many potential data types that the item(s) being dragged can be interpreted as
  • The target handles choosing which type(s) it cares about, and can request the same drag data in multiple different types
stdfmod:
movd esi,xmm0
movd edx,xmm1
mov eax,esi
mov ecx,edx
and eax,0x7fffffff
and ecx,0x7fffffff
cmp eax,ecx
jae 4011a0 <stdfmod+0x30>
cmp ecx,0x7f800000
#! /bin/bash
ilok_details=$(lsusb | grep 'iLok' | grep -P -o '[0-9a-f]+:[0-9a-f]+')
for ilok in $ilok_details; do
ilok_vendor=$(echo $ilok | grep -P -o '^[0-9a-f]+')
ilok_product=$(echo $ilok | grep -P -o '[0-9a-f]+$')
ilok_device=$(cat <<-HERE
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@eira-fransham
eira-fransham / cmykdots-shadertoy.glsl.frag
Last active September 19, 2024 12:12
Best shader for generating CMYK halftone dots for full colour images on the internet, to my knowledge (ShaderToy- and TouchDesigner-compatible)
#define SHADERTOY
#ifdef SHADERTOY
const float Frequency = 60.0;
const float Size = 0.7;
const float Saturation = 5.;
const float Exponent = 0.3;
const float ReduceColor = 0.3;
const float Lightness = 0.306;
const float LumMul = 2.;
#![feature(allocator_api)]
mod cursed_lazy {
use std::{
alloc::{Allocator, Layout, AllocError},
ptr::NonNull,
};
pub struct LazyAlloc;
@eira-fransham
eira-fransham / threadpool.rs
Created September 24, 2021 08:39
Toy threadpool implementation
use std::{
any, mem, panic,
sync::atomic::{AtomicUsize, Ordering},
thread,
};
#[derive(PartialEq)]
enum Progress {
Continue,
Stop,