Skip to content

Instantly share code, notes, and snippets.

View GaryMatthews's full-sized avatar

Gary Matthews GaryMatthews

View GitHub Profile
@GaryMatthews
GaryMatthews / rpn-jit.c
Created May 25, 2019 13:03 — forked from anonymous/rpn-jit.c
RPN JIT Compiler
/* http://redd.it/2zna5q
* Fibonacci example:
* (1) (2) +
* 0:0
* 1:1
* 20
*/
#define _BSD_SOURCE // MAP_ANONYMOUS
#include <stdio.h>
#include <stdlib.h>
@GaryMatthews
GaryMatthews / jit.c
Created May 25, 2019 13:04 — forked from skeeto/jit.c
Basic JIT
/* http://redd.it/2z68di */
#define _BSD_SOURCE // MAP_ANONYMOUS
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <sys/mman.h>
#define PAGE_SIZE 4096
@GaryMatthews
GaryMatthews / uuid.c
Created May 25, 2019 13:07
UUID generator in ANSI C
/* UUID (v4) generator in ANSI C
* $ cc -O3 -o uuid uuid.c
* $ uuid [count]
* Output rate: 30 million UUIDs per second on modern hardware.
* Warning: Generator rolls over after 2^66 UUIDs (or every 78,000 years).
*
* This is free and unencumbered software released into the public domain.
*/
#ifdef _WIN32
# define WIN32_LEAN_AND_MEAN
@GaryMatthews
GaryMatthews / streamtok.c
Created May 25, 2019 13:17
ANSI C line iterator
/* stream tokenizer: strtok() for ANSI C file streams
*
* This provides getdelim()-like functionality, but it is faster than
* your system's detdelim() or getline(). The interface is a bit
* different in order to accomodate its own input buffer.
*
* This file can be compiled as either C or C++.
*
* For the best performance, disable libc stream buffering:
* setvbuf(stream, 0, _IONBF, 0);
@GaryMatthews
GaryMatthews / skyParser.c
Created May 25, 2019 13:46 — forked from HorlogeSkynet/skyParser.c
A simple C string parser for CLI programs
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <inttypes.h>
#define BUFFER 1024
@GaryMatthews
GaryMatthews / curl.md
Created May 27, 2020 05:27 — forked from btoone/curl.md
A curl tutorial using GitHub's API

Introduction

An introduction to curl using GitHub's API.

The Basics

Makes a basic GET request to the specifed URI

curl https://api.github.com/users/caspyin
@GaryMatthews
GaryMatthews / NoPartsBatteryGauge.c
Created December 9, 2020 11:58 — forked from bigjosh/NoPartsBatteryGauge.c
Sample code for a no parts, no pins, no power supply voltage detection on ATTINY84
/*
* NoPartsBatteryGuageAVR.c
*
* This is a simplified demonstration of how to detect power supply voltage by using the on chip
* analog-to-digital converter to measure the voltage of the internal band-gap reference voltage.
*
* The code will read the current power supply voltage, and then blink an LED attached to pin 6 (PA7).
*
* 1 blink = 1 volts <= Vcc < 2 volts (only applicable on low voltage parts like ATTINY84AV)
* 2 blinks = 2 volts <= Vcc < 3 volts
@GaryMatthews
GaryMatthews / lxc.sh
Created January 1, 2022 04:25 — forked from reqshark/lxc.sh
set up linux containers with node.js
# update the host
apt-get update && apt-get upgrade -y # && apt-get dist-upgrade -y && apt-get autoremove --purge -y && apt-get autoclean -y
# https://www.stgraber.org/
# install linux containers
sudo apt-get install lxc
# list all containers and view their current status
sudo lxc-ls -f
@GaryMatthews
GaryMatthews / gist:de6377e5501d2b43d5826e3267fc5c14
Created March 16, 2024 09:28 — forked from ipedrazas/gist:2c93f6e74737d1f8a791
List Docker Container Names and IPs
function drips(){
docker ps -q | xargs -n 1 docker inspect --format '{{ .NetworkSettings.IPAddress }} {{ .Name }}' | sed 's/ \// /'
}