Skip to content

Instantly share code, notes, and snippets.

Avatar

Noa coolreader18

View GitHub Profile
@coolreader18
coolreader18 / segfault.py
Last active May 9, 2022
CPython segfault in 5 lines of code
View segfault.py
class E(BaseException):
def __new__(cls, *args, **kwargs):
return cls
def a(): yield
a().throw(E)
View gmagik.py
#!/usr/bin/env python3
import PIL.Image
from PIL import ImageSequence
import wand.image
from io import BytesIO, RawIOBase
def gmagik(gif: PIL.Image.Image, out: RawIOBase):
total = gif.n_frames
@coolreader18
coolreader18 / odt2md.sh
Last active Jul 26, 2019
Convert a LibreOffice ODT file to a Hugo post.
View odt2md.sh
#!/bin/bash
set -e
case $# in
0)
file=$(
zenity --file-selection \
--file-filter='*.odt' --file-filter='*.docx' --file-filter='*.*' \
--title "Select a document to publish:" \
2>/dev/null
View flame-graph-optimized.html
This file has been truncated, but you can view the full file.
<!doctype html>
<html>
<head>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
@coolreader18
coolreader18 / no-remove-prefix.md
Last active Jul 1, 2019
How to fix Termux without removing $PREFIX
View no-remove-prefix.md

Open Termux (failsafe). Run pkg i libiconv and look at the errors it produces (cat, realpath, etc.). cd to $PREFIX/bin and run

./busybox ln -s busybox {cat,realpath,etc}

for each executable that's missing. When pkg i libiconv doesn't fail, run pkg i coreutils again and everything should be fixed!

View asm.zig
inline fn wa_syscall(nr: usize) usize {
return asm volatile ("swi %[nr]"
: [ret] "={r}" (-> usize)
: [nr] "{i}" (nr)
: "memory", "r1", "r2", "r3", "r4", "r12", "lr"
);
}
inline fn wa_syscall1(nr: usize, p1: usize) usize {
return asm volatile ("swi %[nr]"
View mpwi
#!/bin/bash
INFO_LINES=4
dir=.
while getopts "d:" opt; do
case "$opt" in
d)
dir=$OPTARG
View ref_count.rs
use std::rc::*;
pub enum RefCount<T> {
Rc(Rc<T>),
Weak(Weak<T>),
}
impl<T> RefCount<T> {
pub fn new_rc(value: T) -> RefCount<T> {
RefCount::Rc(Rc::new(value))