Skip to content

Instantly share code, notes, and snippets.

View mlabbe's full-sized avatar

Michael Labbe mlabbe

View GitHub Profile
@mlabbe
mlabbe / ftg_core.h
Created December 7, 2019 07:38
Parse Terminfo binary files without dependency libraries
/* ftg_core.h - v0.5 - Frogtoss Toolbox. Public domain-like license below.
ftg libraries are copyright (C) 2015 Frogtoss Games, Inc.
http://github.com/mlabbe/ftg_toolbox
ftg header files are single file header files intended to be useful
in C/C++. ftg_core contains generally useful functions
Special thanks to STB for the inspiration.
@mlabbe
mlabbe / new.lua
Last active August 23, 2019 19:51
Pico-8 starting point
dev = true
ent_list = {}
types = {}
cam={0,0} -- world top-left
--
-- helpers
--
function get_player(n)
@mlabbe
mlabbe / secgroup.sh
Created June 23, 2019 23:11
Bash script to set an AWS security group to use your current IP address, exclusively. Also works over ipv6 gateways (like your phone tether).
#!/bin/bash
#
# Roaming security group by Michael Labbe
# @frogtoss
#
# security group id
GROUP_ID="sg-xxx"
@mlabbe
mlabbe / clang-format.el
Last active June 17, 2019 20:57
Run clang-format only when projects have a .clang-format in their root, while deferring the load of all packages with use-package
(use-package cc-mode
:defer t
:init
(add-hook 'before-save-hook #'clang-format-buffer-smart)
:config
(progn
(defun clang-format-buffer-smart()
"Reformat buffer only if .clang-format exists in the projectile root."
(when (file-exists-p (expand-file-name ".clang-format" (projectile-project-root)))
(clang-format-buffer)))
@mlabbe
mlabbe / calc.rs
Created March 12, 2019 04:44
A simple calculator in rust (my first rust program)
/*
simple rust calculator
add_op := '+' | '-'
mul_op := '*' | '/'
digits := {'+' | '-'} [0..9] {[0..9]}
expr := term {add_op term}
term := factor {mul_op factor}
factor := digits | '(' expr ')'
@mlabbe
mlabbe / zt.c
Created February 25, 2019 23:40
zero tuple
typedef union {
struct tuple_s { char a; short b; long long c; }tuple;
uint64_t _all[sizeof(struct tuple_s)/sizeof(uint64_t)];
}zero_tuple_u;
int main() {
zero_tuple_u t = {._all = {0}};
}
@mlabbe
mlabbe / quarantine_node.sh
Created September 15, 2018 15:22
Install Quarantined NodeJS to avoid systemwide pollution
export INSTALLDIR=$HOME/dev/node/local # or wherever
mkdir -p $INSTALLDIR
# Put these lines in your .bashrc
export PATH=$INSTALLDIR/bin:$PATH
export MANPATH=$INSTALLDIR/share/man
git clone https://github.com/nodejs/node
cd node
@mlabbe
mlabbe / calc.c
Last active April 30, 2025 20:32
A simple calculator written as an ll1 recursive descent parser
/*
simple calculator implemented via recursive descent
add_op := + | -
mul_op := * | /
digits := {+|-} [0..9] {[0..9]}
expr := term {add_op term}
term := factor {mul_op factor}
@mlabbe
mlabbe / ftg_core.h
Last active December 4, 2021 00:26
/* clang-format off */
/* ftg_core.h - v0.6 - Frogtoss Toolbox. Public domain-like license below.
ftg libraries are copyright (C) 2015-2021 Frogtoss Games, Inc.
http://github.com/mlabbe/ftg_toolbox
ftg header files are single file header files intended to be useful
in C/C++. ftg_core contains generally useful functions
Special thanks to STB for the inspiration.
@mlabbe
mlabbe / gist:5a302600f025ff95fc6e7c04c0def7a3
Created March 11, 2018 21:01
emacsclient icon for Linux Mint Mate Desktop
[Desktop Entry]
encoding=utf-8
Exec=/usr/local/bin/emacsclient -c
Icon=/usr/share/app-install/icons/_usr_share_emacs_21.4_etc_gnu-32x32.xpm
Type=Application
Terminal=false
Comment=Emacs Client
Name=Emacs Client
GenericName=emacsclient
StartupNotify=false