Skip to content

Instantly share code, notes, and snippets.

View ryankurte's full-sized avatar
🥔

ryan ryankurte

🥔
View GitHub Profile
@ryankurte
ryankurte / main.c
Last active April 13, 2024 07:50
Simple C FIFO Queues (aka Ring Buffers)
#define QUEUE_SIZE 16
int main(int argc, char** argv) {
queue_t example = {0, 0, QUEUE_SIZE, malloc(sizeof(void*) * QUEUE_SIZE)};
// Write until queue is full
for (int i=0; i<QUEUE_SIZE; i++) {
int res = queue_write(&example, (void*)(i+1));
assert((i == QUEUE_SIZE - 1) ? res == -1: res == 0);
}
@ryankurte
ryankurte / uart.c
Last active April 1, 2024 11:36
Simple unix serial implementation. This uses pthreads to receive and buffer incoming data for later use.
#include "uart.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <termios.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@ryankurte
ryankurte / gencerts.sh
Last active March 6, 2024 03:38
Node.js Client Certificate Validation with Pinning Example
#!/bin/bash
# https://gist.github.com/ryankurte/bc0d8cff6e73a6bb1950
set -e
if [ "$#" -ne 3 ] && [ "$#" -ne 4 ]; then
echo "Usage: $0 CA NAME ORG"
echo "CA - name of fake CA"
echo "NAME - name of fake client"
echo "ORG - organisation for both"
@ryankurte
ryankurte / morse.md
Last active February 25, 2024 05:12
Morse Code Charts

Morse Code Tables

Helper tables for learning and interpreting morse code.

Ordered Codes

A ._
B _...
C _._.
D _..
E .
@ryankurte
ryankurte / config.toml
Last active February 12, 2024 13:22
Set gitlab runner to use git bash
[[runners]]
name = "tt708-windows"
url = "https://gitlab.com/"
token = "[REDACTED]"
executor = "shell"
shell = "bash"
builds_dir="/c/gitlab-runner/builds/"
cache_dir="/c/gitlab-runner/cache/"
[runners.cache]
[runners.cache.s3]
@ryankurte
ryankurte / whatever.service
Created June 16, 2019 03:41
Minimal systemd unit
# place in /etc/systemd/system/whatever.service and install with `systemd install whatever.service`
# note that if you change this file you will need to run `systemctl daemon-reload` to get systemd to notice
[Unit]
Description=A good service description
# After networking because we need that
After=network.target
[Service]
@ryankurte
ryankurte / backup.env
Last active November 20, 2022 12:02
Linux backup automation
# Systemd environment file for backup.sh daily backup service
# Place in /etc/backup.env
# Destination for rsync file system clone
BACKUP_DEST=/media/large1/backups/raw
# Destination for restic repository
RESTIC_REPOSITORY=/media/large1/backups/restic
# Restic password file
@ryankurte
ryankurte / cross.sh
Created March 10, 2020 00:10
pkg-config multiarch stuff
#!/bin/sh
if [ $TARGET == "x86_64-unknown-linux-gnu" ]; then
cargo build --target=$TARGET --release
elif [ $TARGET == "x86_64-apple-darwin" ]; then
cargo build --target=$TARGET --release
elif [ $TARGET == "armv7-unknown-linux-gnueabihf" ]; then
sh ./cross-linux-armhf.sh
@ryankurte
ryankurte / 10-HuaweiFlashCard.rules
Last active February 17, 2022 18:29
Huawei e3131 Linux Setup
SUBSYSTEMS=="usb", ATTRS{modalias}=="usb:v12D1p1F01*", SYMLINK+="hwcdrom", RUN+="/usr/bin/sg_raw /dev/hwcdrom 11 06 20 00 00 00 00 00 01 00"
@ryankurte
ryankurte / armenv.sh
Last active October 28, 2021 02:23
Project local arm toolchain (gcc-arm-none-eabi) install script for immutable build environments
#!/bin/bash
# Immutable Project-Local Toolchain Setup
# Inspired by Python's virtualenv and npm
# See http://wp.me/pZZvH-an for more
# Run with `source ./armenv.sh`
# TODOs:
# Add upgrade option
# Cleaner toolchain versioning
# Detect different toolchain versions and warn if installing new?