Skip to content

Instantly share code, notes, and snippets.

View FauxFaux's full-sized avatar

Chris West FauxFaux

View GitHub Profile
"""
Benchmark: sorting dates by line number with file-seek access.
Simulates the production workflow where we hold only line numbers in memory
and must open the file, seek to the correct line, read the date string, and
parse it for every comparison the sort makes.
"""
from datetime import datetime, timedelta
from time import perf_counter
import {createServer} from "node:net";
async function main() {
createServer(() => {})
// .listen(0);
console.log('going to hang forever:');
await new Promise(() => {});
console.log('finished hanging');
}
{"name":"yo","version":"yes","scripts":{"postinstall":"mkdir specs; echo hey, whassup > specs/spec.md"}}
# Place a copy of this config to ~/.aerospace.toml
# After that, you can edit ~/.aerospace.toml to your liking
# You can use it to add commands that run after login to macOS user session.
# 'start-at-login' needs to be 'true' for 'after-login-command' to work
# Available commands: https://nikitabobko.github.io/AeroSpace/commands
after-login-command = []
# You can use it to add commands that run after AeroSpace startup.
# 'after-startup-command' is run after 'after-login-command'
use bitfield_struct::bitfield;
#[bitfield(u8)]
struct Status {
#[bits(4)]
tag: u8,
#[bits(4)]
channel: u8,
}
use anyhow::Result;
use std::net::SocketAddr;
use tokio::io::{AsyncBufReadExt, AsyncWriteExt, BufReader};
use tokio::net::{TcpListener, TcpStream};
async fn echo(mut socket: TcpStream, addr: SocketAddr) -> Result<()> {
println!("Incoming connection from: {}", addr);
let (read, mut write) = socket.split();
let mut read = BufReader::new(read);
write.write_all(b"Welcome!").await?;
[package]
name = "paper-events"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = "1"
itertools = "0.13"
bincode = { version = "2.0.0-rc.3", features = ["derive"] }
rand = "0.8"
async function throws() {
throw new Error('I threw!');
}
async function main() {
const result = throws();
console.log('seven');
await sleep(10);
console.log('nine');
await result;
@FauxFaux
FauxFaux / 1-demo.js
Created January 15, 2024 19:44
node-forge-fromDer
const forge = require("node-forge");
const badKeyValue = `MGsCAQEEIDrDtTbDnMKRwpvDpzkxLQpwO8O8w6zDq8OWwo
HCtcKedjrDgsOCMMOiw4rDqBsewpDCucKhRANCAAQ/c3zDq8K4wpnDvcO6N3nChsOUfnHD
k8OcQsORwqHCtMKFwrvCq08mw77CnsOHAl7DliQAwrsJX8OWYWzCn2lVw5DCg8OIeGfDpM
KxK8O4wr3Cn8OFdsO1HVhbw4xGWmbCpw==`;
const goodKeyValue = `MGsCAQEEIEjDv8KoIcO5wrrChl3DsUDDvXjDpMOYwrHDjMKKw
55pMT7CrMK8O8KQIsOTasK5SUZ7wqFEA0IABAQxUMOWennChGpcwoTDhsOvUzgeFsK3w7bCscK1wo
MDwrEuX8OPwrTCn8KUKcOiYcOtw6JRw7LDrSPCvMOtw4t/w4PDlcOQw5zDqiTCjDbCocKowpXCjMK
]i=:'467..114..',LF,'...*......',LF,'..35..633.',LF,'......#...'
]l=:;;. _1 (LF,i)
]n=:a.{~48+i.10
]b=:n,'.'
]q=:l e.n
]s=:((-.l e.b),0),.(5 $ 0)
]r=:a:-.~"1(1,"1-.q)<;._2 i.>:{:$q
]p=:,{{ (}.y),"0&.>"0(>{.y)}}"1 ((;/i.4),.r)
]w=:{{0>.(({.y)-0 1),y,(({:y)+0 1)}}&.>"0 p
]f=:{{0>.(y-"1 (1 0)),y,(y+"1 (1 0))}}&.>"0 w