Skip to content

Instantly share code, notes, and snippets.

View brandon1024's full-sized avatar
💻
C/GO/JAVA

Brandon Richardson brandon1024

💻
C/GO/JAVA
View GitHub Profile
@brandon1024
brandon1024 / README.md
Last active January 24, 2024 15:25
Wireguard Exporter [Node Exporter Textfile Collector]

A Simple Solution for Wireguard Interface and Peer Metrics Exposition to Prometheus

Here's a simple set of scripts that allow you to export wireguard tunnel statistics to a file in Prometheus text format. This file can be read by the node_exporter textfile collector, for example.

You might be asking, why does this exist? Why not MindFlavor/prometheus_wireguard_exporter? The reality is that a full-fledged webserver written in Rust to expose wireguard metrics is a bit overkill. I've accomplished the same thing in ~100 lines of (well documented) Awk. It's dead simple, and a no brainer if you're already using node-exporter.

For those conscious about security, you'll be happy to know the script itself does't run any wireguard commands; it doesn't even need to be run as root. It accepts a wg dump from stdin, and that's it. The metrics exposition is completely isolated from the wiregu

@brandon1024
brandon1024 / README.md
Last active May 13, 2022 23:34
The Dumbest Dynamic DNS [Route53]

A Dumb Route53 Dynamic DNS Solution

There's really not much to it.

You'll need an AWS Route53 hosted zone and a suitable AWS user. Install and configure AWS CLI. Update ddns-sync.sh variables (DNS_NAME and HOSTED_ZONE_ID) appropriately. Then,

$ cp ddns-sync.sh      ${HOME}
$ cp ddns-sync.service ${HOME}/.config/systemd/user/
$ cp ddns-sync.timer   ${HOME}/.config/systemd/user/
$ systemctl --user enable ddns-sync.service
@brandon1024
brandon1024 / format-string-directives.md
Last active December 25, 2020 17:38
Common Format String Directives for Various Data Types in C

Common Format String Directives for Various Data Types in C

I find myself often having trouble picking the right format string specifiers (or directives), so this is a cheat sheet. Maybe this can help others too.

These lists are not exhaustive (and not guarenteed to be platform agnostic), but will be updated as I encounter new types and directives.

Standard Data Types

  • char %c (or %hhi for numerical)
    • signed char
  • unsigned char %c (or %hhu for numerical)
  • short %hi
@brandon1024
brandon1024 / git-contributing.md
Last active March 3, 2019 20:05
Workflow for Contributing to Git Core
@brandon1024
brandon1024 / ExtJS-vs-ReactJS.md
Last active December 11, 2023 07:30
A Comparison of Legacy and Modern Frontend Frameworks in Enterprise Software

A Comparison of Legacy and Modern Frontend Frameworks in Enterprise Software

TL;DR

At the time of its release, ExtJS was seen by the software development community as an incredible innovation in the world of JavaScript frontend frameworks. However, over time ExtJS consistently fell short and shook the fleeing community it had once established. Result of a complicated complex architecture, performance issues, and several licensing controversies, several other frameworks had been introduced into a space where ExtJS, once a popular framework for building enterprise software, had fallen short. With a disappearing community, meager documentation, poor performance and significant licensing cost, ExtJS is quickly becoming a deprecated technology.

One such framework, ReactJS, entered into the space to compete against ExtJS and other big players in the industry; a promising framework that was lightning fast, robust and easy to maintain. Over the years since its release, it has gained significant traction and h

@brandon1024
brandon1024 / GITCRASHCOURSE.MD
Last active May 5, 2024 18:37
Git Crash Course for Beginners

Git Crash Course for Beginners

Preface

A good understanding of Git is an incredibly valuable tool for anyone working amongst a group on a single project. At first, learning how to use Git will appear quite complicated and difficult to grasp, but it is actually quite simple and easy to understand.

Git is a version control system that allows multiple developers to contribute to a project simultaneously. It is a command-line application with a set of commands to manipulate commits and branches (explained below). This tutorial will help you get started, and in no time you will be a Git Ninja!

Contents:

@brandon1024
brandon1024 / BatteryStatusNotification.scpt
Last active April 21, 2024 07:09
Battery Percentage Boundary Notification Background Script for macOS
repeat
set chargeState to do shell script "pmset -g batt | awk '{printf \"%s %s\\n\", $4,$5;exit}'"
set percentLeft to do shell script "pmset -g batt | egrep -ow '([0-9]{1,3})[%]' | egrep -ow '[0-9]{1,3}'"
considering numeric strings
if chargeState contains "Battery Power" and percentLeft ≤ 40 then
display notification "Time to plug me in :)" with title "Battery Charge Boundary"
else if chargeState contains "AC Power" and percentLeft ≥ 80 then
display notification "Time to unplug me :)" with title "Battery Charge Boundary"
end if
end considering
@brandon1024
brandon1024 / FacebookMessengerApp.md
Last active January 7, 2019 00:50
Using Chrome Flags for Simple Facebook Messenger Desktop Client

Facebook Messenger Desktop Client

Preface

Back in 2011, Facebook released a desktop Facebook Messenger client, but its existence was shortlived. After a couple of years the useful app became obsolete, and although a number of third-party apps persisted, most weren't very well executed. Furthermore, you can't always be sure that the third-party messenger app doesn't compromise the security of your personal conversations.

I discovered something today that I knew I had to share. Chromium (and Chrome) have an extensive list of command line flags (known as "switches") that can be used to customize your browser beyond the features available through the UI. One in particular, --app, will start a new instance of Chrome in application mode. This mode essentially runs Chrome without an address bar, borders, tabs, etc. Using this feature, we can run a simple desktop application based on a web app. Continue reading and I'll show you what I mean.