Skip to content

Instantly share code, notes, and snippets.

View tlkahn's full-sized avatar
🥫

Leo tlkahn

🥫
View GitHub Profile
@tlkahn
tlkahn / fast_conway_mlx.py
Created August 31, 2024 02:12 — forked from awni/fast_conway_mlx.py
Conway's Game of Life Accelerated with Custom Kernels in MLX
import av
import numpy as np
import mlx.core as mx
def conway(a: mx.array):
source = """
uint i = thread_position_in_grid.x;
uint j = thread_position_in_grid.y;
uint n = threads_per_grid.x;
@tlkahn
tlkahn / elf_format_cheatsheet.md
Created March 15, 2024 11:52 — forked from x0nu11byt3/elf_format_cheatsheet.md
ELF Format Cheatsheet

ELF Format Cheatsheet

Introduction

Executable and Linkable Format (ELF), is the default binary format on Linux-based systems.

ELF

Compilation

@tlkahn
tlkahn / README.md
Created June 22, 2022 00:40 — forked from PurpleBooth/README.md
A github workflow pipeline for rust that does test, build and deploy windows, linux and mac, creates releases, and does SemVer Versioning, and releases to a homebrew tap

Features

  • Automatically bump SemVer
  • Update a personal homebrew tap
  • Keep that pesky version in the Cargo.toml up to date
  • (From dependabot) Get new versions out as soon as possible

Assumptions

  • You don't want a changelog
@tlkahn
tlkahn / tmux-cheatsheet.markdown
Created June 10, 2022 02:06 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
#!/usr/bin/env python
# parse_toc.py
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
def parse(filename, maxlevel):
fp = open(filename, 'rb')
parser = PDFParser(fp)
doc = PDFDocument(parser)
@tlkahn
tlkahn / main.c
Created October 10, 2017 06:47 — forked from fur-q/main.c
C/Lua interop basic example
static int cf_tolua(lua_State *L) {
lua_pushliteral(L, "hello");
return 1;
}
static int cf_fromlua(lua_State *L) {
const char *str = lua_tostring(L, 1); // first argument passed in; second would be at index 2
printf("%s\n", str);
return 0;
}
@tlkahn
tlkahn / match.c
Created September 25, 2017 13:39 — forked from ianmackinnon/match.c
C Regex multiple matches and groups example
# gcc -Wall -o match match.c && ./match
#
#include <stdio.h>
#include <string.h>
#include <regex.h>
@tlkahn
tlkahn / function_invocation.js
Created June 18, 2017 20:44 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
@tlkahn
tlkahn / vimregex-juan_auras_lester.md
Created March 15, 2017 13:33 — forked from dreftymac/vimregex-juan_auras_lester.md
vim regular expressions for perl regex fans

Overview

Vim regular expressions are powerful, but they pre-date Perl.

This can be frustrating since the Perl-flavored-regex syntax has expanded beyond into other programming languages and contexts, becoming a de-facto standard.

This guide is a quick cheatsheet and tipsheet for using regular expressions in Vim for those who may be more familiar with Perl.

Quick examples for vimmers who like Perl regex

@tlkahn
tlkahn / adt.c
Created June 17, 2016 22:21 — forked from hosaka/README.md
Abstract Data Type using opaque pointers in C
#include <stdio.h>
#include <stdlib.h>
#include "array_api.h"
// abstract array data type types
// opaque pointer:
// an ADT implementation hidden behind the interface that is abstract to
// the client, making it easier to maintain, apply changes and improve
// in this example the array_t data type provides a bunch of functins