Skip to content

Instantly share code, notes, and snippets.

View coolreader18's full-sized avatar

Noa coolreader18

View GitHub Profile
@coolreader18
coolreader18 / cleanedup-macro-io.rs
Last active January 4, 2019 06:00
Different versions of io.rs's mk_module, using macros or not
// the expanded version, with attributes and variable names cleaned up
let ctx: &PyContext = ctx;
let py_mod = ctx.new_module("io", ctx.new_scope(None));
let IOBase = {
ctx.new_class("IOBase", ctx.object())
};
ctx.set_attr(&py_mod, "IOBase", IOBase.clone());
let StringIO = {
let py_class = ctx.new_class("StringIO", IOBase.clone());
let __init__ = ctx.new_rustfunc(string_io_init);
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))
#!/bin/bash
INFO_LINES=4
dir=.
while getopts "d:" opt; do
case "$opt" in
d)
dir=$OPTARG
This file has been truncated, but you can view the full file.
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]"
@coolreader18
coolreader18 / no-remove-prefix.md
Last active July 1, 2019 23:29
How to fix Termux without removing $PREFIX

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!

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;
padding: 0;
This file has been truncated, but you can view the full file.
{"$schema":"https://www.speedscope.app/file-format-schema.json","profiles":[{"type":"evented","name":"RustPython main","unit":"nanoseconds","startValue":399,"endValue":53408720,"events":[{"type":"O","at":113364,"frame":0},{"type":"O","at":117875,"frame":1},{"type":"C","at":564580,"frame":1},{"type":"C","at":2547506,"frame":0},{"type":"O","at":2548124,"frame":2},{"type":"O","at":3372050,"frame":3},{"type":"O","at":3395560,"frame":4},{"type":"C","at":3399468,"frame":4},{"type":"O","at":3400019,"frame":5},{"type":"C","at":3400536,"frame":5},{"type":"O","at":3401015,"frame":6},{"type":"C","at":3401211,"frame":6},{"type":"O","at":3402361,"frame":7},{"type":"C","at":3432454,"frame":7},{"type":"O","at":3434631,"frame":8},{"type":"C","at":3438657,"frame":8},{"type":"O","at":3439454,"frame":9},{"type":"C","at":3439965,"frame":9},{"type":"O","at":3440829,"frame":10},{"type":"C","at":3460624,"frame":10},{"type":"O","at":3461106,"frame":11},{"type":"C","at":3461453,"frame":11},{"type":"O","at":3463211,"frame":12},{"type"
@coolreader18
coolreader18 / odt2md.sh
Last active July 26, 2019 18:24
Convert a LibreOffice ODT file to a Hugo post.
#!/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
#!/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