Skip to content

Instantly share code, notes, and snippets.

View charles-l's full-sized avatar
👾
making games

Charles charles-l

👾
making games
View GitHub Profile
def kalman_predict(x_hat, u, P, wheel_slip_std):
# non-linear state transition
def f(p, u):
x, y, θ = p
dΦ_l, dΦ_r = u
return v(
x + (((WHEEL_R * dΦ_l) / 2) +
((WHEEL_R * dΦ_r) / 2)) * DT * cos(θ),
y + (((WHEEL_R * dΦ_l) / 2) +
((WHEEL_R * dΦ_r) / 2)) * DT * sin(θ),
@charles-l
charles-l / fretboard.rkt
Created January 7, 2018 14:44
Quick script to draw SVG fretboards. For yak-shaving purposes.
#lang racket
(require racket/draw)
(define string-dist 15)
(define fret-dist 20)
(define strings 6)
(define (draw-gstring dc frets x h)
@charles-l
charles-l / llvm_writeup.md
Last active January 11, 2021 00:40
LLVM GSoC Writeup

GSoC 2017 Project

This summer, I worked on adding more attributes to ThinLTO's index to allow for more optimizations.

Background

LTO (Link-time optimization) combines the bitcode of every module in a project into a monolithic bitcode file during linking, so IPO (interprocedural optimizations) can be applied throughout a whole program. This improves the quality and the speed of the executables generated. However, LTO consumes a large amount of memory, so it isn't viable on many larger C/C++ codebases.

ThinLTO addresses this problem by introducing a light-weight in-memory index, that tracks attributes for relevant global values in a program. The index can be used to propagate information across a whole program, import and internalize functions, and apply whole program optimizations without having to store all the bitcode in memory.

@charles-l
charles-l / meta.scm
Last active November 10, 2023 17:15
metacircular evaluator from sicp
;; metacircular evaluator from sicp
(define apply-in-underlying-scheme apply)
(define (list-of-values exps env)
(if (no-operands? exps)
'()
(cons (eval (first-operand exps) env)
(list-of-values (rest-operands exps) env))))
(define (eval-if exp env)
(if (true? (eval (if-predicate exp) env))
@charles-l
charles-l / notifyd.c
Last active November 2, 2016 21:27
a simple notification service demo
// a simple notification daemon that sits on a fifo and calls a popup commend when new lines appear
// to use:
// cc -o notifyd notifyd.c
// ./notifyd
// <in a different terminal>
// echo 'a wild notification appears!' > /etc/notidsock
// <bask in the glory of a simple notification service that's less than 100 lines of code>
#include <stdio.h>
#include <unistd.h>
@charles-l
charles-l / main.lua
Last active October 29, 2016 18:57
End of tutorial 1 for the polished platformer series
bump = require 'bump'
local world = bump.newWorld()
local level = {elems = {}}
function level:addElem(x, y, w, h, drawLambda)
local t = {draw = drawLambda}
world:add(t, x, y, w, h)
table.insert(self.elems, t)
@charles-l
charles-l / send_data_through_pipe.c
Last active April 30, 2016 00:58
Simple C program to send data through one end of a pipe, to a command, then read it back in.
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
// p pp
// (input - sent to first pipe) | tr a b | (output - read back in)
int main (void) {
int p[2];
@charles-l
charles-l / exploit.c
Last active April 14, 2016 05:34
exploit to solve pwn1 in the sctf challenge
#include <stdio.h>
// TO RUN EXPLOIT (this file just generates the junk needed to overflow to the return address):
// cc exploit.c; ./a.out | nc problems2.2016q1.sctf.io 1337
int main() {
// EIP points to the current stack frame (so we want it to point at get_flag)
//
// We can do this by overwriting the old return address with the address for get_flag
// (which you can get by running `pd 1 @ sym.get_flag` in radare)
#!/usr/bin/env python
import gdb
class ListPrintCommand(gdb.Command):
"""print atoms"""
def __init__(self):
super(ListPrintCommand, self).__init__("print-atom",
gdb.COMMAND_DATA, gdb.COMPLETE_SYMBOL)
@charles-l
charles-l / bwop.vim
Created November 3, 2015 02:07
Very simple color scheme (only highlights comments/strings)
hi clear
set background=dark
if exists("syntax_on")
syntax reset
endif
let g:colors_name = "bwop"
hi Normal ctermfg=7 ctermbg=0
hi Directory ctermfg=gray
hi Search ctermfg=white ctermbg=blue