Skip to content

Instantly share code, notes, and snippets.

@oconnor663
oconnor663 / my_mutex.cpp
Created July 23, 2022 00:26
Mutex as a container in C++
#include <iostream>
#include <mutex>
#include <thread>
#include <vector>
template <typename T> class MyMutex;
template <typename T> class MyMutexGuard;
template <typename T> class MyMutex {
friend class MyMutexGuard<T>;
0eNrNfUtvHElz7V8ZaN1tVEbkc5Y27LsycOFZGsQHjtSjIT6KJJqk58419N9dTUpdRSof50TX2F4MBHHEk5FRGZERkfH4zw+/3j4fHo43d09/+/X+/u8ffv7P5SePH37+99VfT//v5uP93euPH28+313fnn729OfD4cPPH26eDl8+7D7cXX85/e3x6f7usP/t+Xh3/fHw4evuw83dp8P/+/Cz+3q1+3C4e7p5ujm8Ar385c+/3T1/+fVwnP/BGeLpeH33+HB/fNr/erh9mqEf7h/nX7u/Oy06Q3n3D2H34c8PP+99/ocwL/Hp5nj4+PoP5OvuB2TBkScOWXFk4ZA9jqwccsCRPYccceTAISccOXHIGUeOHHLBkQuH7CYcOpPQziIrM2e+1sAWwXuelcDx8/F+/nMs1OmF0u/a5e7h+elDDV1t6HGNfv/81IL3Fk6kBicWobu5ezwcn+Yf9gS5BRMbaraC9X23VZyEkBOG5CzC8/jl+vZ2f7idz9bx5uP+4f720NUnr5/47nDz+fdf75+PpwtB/E7lqrZMgXcderuWCdl1Gu1aHExO6pIjCDllSI7C5JQuOZ78mLn3MeejoaH2MWWRhMeH25un6q512TVyvUeLpPr36tDXoJMFOjS+VAa2vlJU7+iLNchiMUB+2HoNWidOZfn6ptVxqqYFI2ZV4xuncxdL7YCqclqiRbDnpLsFE8xS6Rsqdpdidd+RuE5XAqo/HCbgclWTXAkispptZoFCRocWRIZlRXDNtp8su1dk995ZFII26BROBUDfx1NmmyLnrPm1vOeUD7aBYHFzFNG5Plp8Mwza5EJh0JnTmBiXi8Uxg+gNk8Uzw6CdxTPDoElzEeJyMPpQDvOhgsmHchDlwQI9QdC8l+Vq6jMk2m+p42Ta4ajjFNpTqOJEy/WlWATJEgQEoS1RwJOdMz4w0RIGBKm2xAFBaC4mAbLCEgME6U2GyxGEzpSdALKiWF2Wb/hvTPem3Z4mw0WJsSU5g80AQgtlM2AcT2q42EF
@oconnor663
oconnor663 / early_bao_talk_subtitles.ass
Created May 13, 2022 04:00
early Bao video subtitles
[Script Info]
; Script generated by Aegisub 3.2.2
; http://www.aegisub.org/
Title: Default Aegisub file
ScriptType: v4.00+
WrapStyle: 0
ScaledBorderAndShadow: yes
YCbCr Matrix: TV.601
PlayResX: 1280
PlayResY: 720
@oconnor663
oconnor663 / blake3_Cargo.toml
Created March 24, 2022 18:32
BLAKE3 and SHA-256 power usage
[package]
name = "blake3_loop"
version = "0.1.0"
edition = "2021"
[dependencies]
blake3 = "1.3.1"
ctrlc = "3.2.1"
rand = "0.8.5"
@oconnor663
oconnor663 / main.rs
Last active March 14, 2022 17:36
calling conventions
#[cfg(unix)]
std::arch::global_asm!(
"with_rsp:",
"xor rax, rax",
"add rax, rdi",
"shl rsi, 1",
"add rax, rsi",
"shl rdx, 2",
"add rax, rdx",
"shl rcx, 3",
@oconnor663
oconnor663 / _readme.md
Last active March 4, 2022 17:43
running blake3-py tests against the proposed hashlib implementation
@oconnor663
oconnor663 / ownership_and_defer.zig
Created January 28, 2022 17:58
An example of how defer/errdefer interacts with ownership.
const std = @import("std");
const Allocator = std.mem.Allocator;
const ArrayList = std.ArrayList;
const Person = struct {
pet: Pet,
const Self = @This();
// Takes ownership of pet.
@oconnor663
oconnor663 / ..json_parsing_examples
Last active January 26, 2022 22:19
JSON parsing examples
We couldn’t find that file to show.
@oconnor663
oconnor663 / Cargo.toml
Created November 21, 2021 23:26
HKDF collision between different salts
[package]
name = "scratch"
version = "0.1.0"
edition = "2021"
[dependencies]
hex = "0.4.3"
hkdf = "0.11.0"
sha2 = "0.9.8"
@oconnor663
oconnor663 / _windows_scripts
Last active November 14, 2021 03:36
windows scripts
.