Skip to content

Instantly share code, notes, and snippets.

View pkage's full-sized avatar
🛠️
writing

Patrick Kage pkage

🛠️
writing
View GitHub Profile
@pkage
pkage / orbit.py
Last active September 18, 2023 05:10
orbital sim to show why dot product disambiguates position in orbit
# adapted from:
# https://astronomy.stackexchange.com/questions/7806/exercise-2d-orbital-mechanics-simulation-python
import matplotlib.pyplot as plt
import math
plt.ion()
plt.style.use('dark_background')
@pkage
pkage / main.c
Created July 15, 2023 15:43
spi 20x6bit -> 20x8bit unstuff
#include <stdio.h>
#include <stdlib.h>
// assumes little endian
void print_bits(size_t const size, void const * const ptr)
{
unsigned char *b = (unsigned char*) ptr;
unsigned char byte;
int i, j;
@pkage
pkage / aws_presigned_url_reqpays.py
Last active April 27, 2023 19:44
RequesterPays presigned URL failure with AWS4-HMAC-SHA256
import boto3
from botocore.client import Config
client = boto3.client(
's3',
'us-west-2',
# replace with your credentials
aws_access_key_id='AWS_ACCESS_KEY_ID',
aws_secret_access_key='AWS_SECRET_ACCESS_KEY',
@pkage
pkage / draftmode.tex
Created December 14, 2021 18:20
Patrick's draft mode latex thing
\usepackage{xcolor}
\usepackage{framed}
\usepackage{ifthen}
\newboolean{draftenabled}
\setboolean{draftenabled}{false} % change to enabled to show notes
\ifthenelse{\boolean{draftenabled}}
{
\newenvironment{draft}{
@pkage
pkage / init.vim
Created May 8, 2021 10:56
2021 vim config
set nocompatible
call plug#begin('~/.local/share/nvim/plugged')
" Quality of life
Plug 'tpope/vim-sensible'
Plug 'vim-airline/vim-airline'
Plug 'scrooloose/nerdtree'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'mhinz/vim-startify'
@pkage
pkage / caffienate.sh
Created May 1, 2019 10:25
caffienate your dice machine
#! /bin/sh
echo "keeping screen awake... (ctrl-c to exit)"
# literally move the mouse back and forth every ten minutes
while [ true ]
do
xdotool mousemove_relative --sync -- 1 0
xdotool mousemove_relative --sync -- -1 0
sleep 600
@pkage
pkage / Dockerfile
Created October 23, 2020 07:21
Dockerfile for ROS over noVNC
FROM dorowu/ubuntu-desktop-lxde-vnc:bionic-lxqt
RUN \
apt-get update && \
apt-get install -y \
dirmngr \
python3-pip && \
sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list' && \
apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654 && \
apt-get update && \
@pkage
pkage / .zshrc
Created June 18, 2020 00:57
06.17.2020 dotfiles dump
autoload bashcompinit
bashcompinit
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
setopt autocd
bindkey -v
@pkage
pkage / thumbnail_browser.html
Last active April 13, 2020 05:54
clicky clicky
<!DOCTYPE html>
<html>
<head>
<title>foo</title>
</head>
<body>
<img id="big"/>
<div id="thumbs"></div>
@pkage
pkage / ocean_demo.c
Created April 15, 2018 04:17
Very basic demo of the Ocean web server
#include "ocean.h"
// test handler - returns the requested path
struct Response* test_handler(struct Request* req) {
printf("example handler firing!\n");
struct Response* res = create_response();
// custom resonse packing
set_response_status(res, 200, "OK");