Skip to content

Instantly share code, notes, and snippets.


Charles charles-l

View GitHub Profile
charles-l /
Last active Feb 22, 2021
GDB command to visualize the raw memory for the current stack frame
class RawFrame(gdb.Command):
"""Dump the raw memory for the stack while visualizing a stack frame"""
def __init__ (self):
super().__init__('raw-frame', gdb.COMMAND_USER)
def invoke(self, arg, from_tty):
sp = gdb.selected_frame().read_register('rsp').cast(gdb.lookup_type('unsigned char').pointer())
bp = gdb.selected_frame().read_register('rbp').cast(gdb.lookup_type('unsigned char').pointer())
def hex_word(addr, length=8):
charles-l /
Last active Nov 29, 2020
A python script to save the Firefox Reader view of a page with images. Kind of a personal tool but using zip and HTML files rather than WARC.
#!/usr/bin/env python3
from bs4 import BeautifulSoup
from readability import Document
import click
from click import echo
import requests
import slugify
import os
charles-l /
Created Aug 24, 2020
Render a noise pattern onto an image in Blender
import bpy
import numpy as np
from mathutils import noise
img =['some-img']
w, h = img.size
# 4 channel image (RGBA), f64
a = np.array(img.pixels).reshape((h, w, 4))
charles-l /
Created Jun 7, 2020
has_many relationship from Rails for Pandas
import pandas as pd
class RelationshipAccessor:
Add a relationship accessor to dataframe objects allowing Rails-like
access to related dataframes. e.g.
>>> authors = pd.DataFrame({'name': ['C. S. Lewis', 'Lewis Carroll']})
>>> books = pd.DataFrame({'title': ["Alice's Adventures in Wonderland",
charles-l /
Created May 23, 2020
An eBPF frame tracer tool written in Python
Expects probes to be defined in the target process, e.g.:
import stapsdt
provider = stapsdt.Provider('game')
frame_begin_probe = provider.add_probe('frame_begin')
frame_end_probe = provider.add_probe('frame_end')
charles-l / hexdump.zig
Last active May 7, 2020
Small hexdump utility written in zig to test the language out a bit.
View hexdump.zig
const std = @import("std");
pub const BlockIterator = struct {
buffer: []const u8,
block_size: usize,
index: usize,
pub fn next(self: *BlockIterator) ?[]const u8 {
if (self.index == self.buffer.len) {
return null;
charles-l /
Created Apr 26, 2020
hexahue decoder
# decodes hexahue images
import cv2
import numpy as np
codewords = {'mrgybc': 'a',
'rmgybc': 'b',
'rgmybc': 'c',
'rgymbc': 'd',
'rgybmc': 'e',
'rgybcm': 'f',
charles-l / guix
Created Apr 9, 2020
openrc init script for guix daemon
View guix
description="daemon required by the guix package manager"
from typing import Callable, Any
from dataclasses import dataclass
class _CpsA: # (x, k) -> ()
def lift(f) -> '_CpsA':
return _CpsA(lambda x, k: k(f(x)))
def __init__(self, cps: Callable[[Any, Callable], None]):
self.cps = cps
charles-l / Makefile
Last active Jan 10, 2019
c++ compile times
View Makefile
FILES=$(wildcard *.cpp)
NJOBS=$(shell echo $$(nproc) + 1 | bc)
g++ $(FILES)
echo "int main() {}" > main.cpp
for i in `seq 500`; do touch f$$i.cpp; done