Skip to content

Instantly share code, notes, and snippets.

@nixpulvis
nixpulvis / bench.svg
Last active October 22, 2026 02:47
parser-combinator benchmarks: string->json relative to Racket's json, log scale
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
use std::marker::PhantomPinned;
use std::ops::Deref;
use std::pin::{Pin, pin};
struct NoMove(i32, PhantomPinned);
impl Deref for NoMove {
type Target = i32;
fn deref(&self) -> &Self::Target {
#![feature(rustc_private)]
extern crate rustc_hir;
extern crate rustc_middle;
// Doesn't work.
use rustc_hir::intravisit::Visitor;
use rustc_middle::ty::TyCtxt;
@nixpulvis
nixpulvis / temperature-alarm.sh
Created November 24, 2021 16:10
Watching the weather is serious stuff, better use bash.
#!/bin/sh
alarm() {
while :;
do
play ~/Loud_Alarm_Clock_Buzzer-Muk1984-493547174.wav
done
}
while :;
$ events --today
┍━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┑
│ Thursday 2020-10-08 │
├─────────────────────────────────────────────────────────────────────────────┤
│ ▾ Groceries │
│ ☒ Coffee │
│ ▸ Readings (due: 10-20) │
└─────────────────────────────────────────────────────────────────────────────┘
union U {
u32: u32,
u64: u64,
f32: f32,
f64: f64,
}
fn main() {
let u32 = U { u32: 1 };
let u64 = U { u64: 1 };
let highlights = execute('highlight')
let highlights = substitute(highlights, '\n\s\+', ' ', 'g')
let highlights = split(highlights, '\n')
call map(highlights, "split(v:val, '\\s\\+xxx\\s\\+')[0]")
for group in highlights
execute 'highlight' group 'NONE'
endfor
@nixpulvis
nixpulvis / median.rb
Created April 28, 2020 22:55
Median of Medians Algorithm
# Common median algorithm, which averages the two middle
# values when needed.
def median(list)
sorted = list.sort
half = (list.size - 1) / 2
if list.size.even?
(sorted[half] + sorted[half+1]) / 2.0
else
sorted[half]
end
@nixpulvis
nixpulvis / dhm.rs
Created March 16, 2020 03:29
Diffe-Hellman-Merkle Key Exchange Demonstration (using curves crate)
//! ```cargo
//! [dependencies]
//! rand = "0.3.16"
//! curves = { git = "https://gitlab.com/neucrypt/curves", branch = "release" }
//! ```
extern crate rand;
extern crate curves;
use curves::{Secp, SecpOrd, ECGroup, Ford};
/// This demonstrates the math beneath a Diffe-Hellman-Merkle key exchange, and
@nixpulvis
nixpulvis / unicode.txt
Created January 27, 2020 16:17
Test Unicode File
From xiangkangzzz@163.com Sat Sep 28 21:28:52 2019
Date: Sat, 28 Sep 2019 12:23:51 +0800
From: 0 <xiangkangzzz@163.com>
Reply-To: billie@joawamould.com
Subject: E-017-00260_28
Message-ID: <201909281224045885357@163.com>
X-Mailer: Foxmail 7, 0, 1, 91[cn]
Dear ask