Skip to content

Instantly share code, notes, and snippets.

View bynect's full-sized avatar
🙄
Procrastinating

nect bynect

🙄
Procrastinating
  • Laniakea Supercluster
  • 04:32 (UTC +02:00)
View GitHub Profile
#!/bin/bash
# NOTE: This script exports only one uid
key_pattern=
remote_host=
remote_path=/var/www/html/.well-known/openpgpkey/hu/
for item in $(gpg --list-secret-keys --with-colons ${key_pattern:- } \
| awk -F: '($1 == "sec" && $2 == "u") { print $5}'); do
@bynect
bynect / invoke.c
Last active September 22, 2022 13:05
#define invoke(inst, meth, ...) (inst)->meth((inst), __VA_ARGS__)
@bynect
bynect / char-counter.cpp
Created June 28, 2022 17:17
Count (ascii) char occurrences in any utf8 file
#include <cctype>
#include <cstdint>
#include <fstream>
#include <iostream>
#include <locale>
#include <algorithm>
int main(int argc, char **argv)
{
std::locale::global(std::locale(""));
@bynect
bynect / build.sh
Last active June 20, 2022 16:09
Grid with 2d rotation example in SDL2
#!/bin/sh
set -xe
gcc -o main main.c -lSDL2
@bynect
bynect / svg.rs
Created August 29, 2021 13:13
Mini svg library in Rust
pub struct SVG {
text: String,
height: usize,
width: usize,
}
const INDENT: &str = " ";
const XMLNS: &str = "http://www.w3.org/2000/svg";
const XLINK: &str = "http://www.w3.org/1999/xlink";
@bynect
bynect / life_standalone.rs
Created August 24, 2021 16:08
Standalone Game of Life implementation in Rust. Uses libc's rand and srand functions for generating random grids.
use std::thread::sleep;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
#[derive(Debug, Copy, Clone)]
enum Cell {
Dead = 0,
Live = 1,
}
impl Cell {
@bynect
bynect / life.rs
Last active August 24, 2021 16:07
Game of Life implementation in Rust. Depends on the rand crate for generating random grids.
use std::thread::sleep;
use std::time::Duration;
// Add rand in the dependencies section of Cargo.toml
use rand::Rng;
#[derive(Debug, Copy, Clone)]
enum Cell {
Dead = 0,
Live = 1,
@bynect
bynect / Makefile
Last active August 23, 2021 00:52
Very basic color gradient application made with OpenGL and glfw.
# Uncomment -DDYN_PROCS if dynamic loading of OpenGL function is preferable over static linking
CFLAGS=-O2 -Wall -Wextra #-DDYN_PROCS
LDFLAGS=-lglfw -lGL
gradient: gradient.o
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $^
%.o: %.c
$(CC) -o $@ -c $(CFLAGS) $^
@bynect
bynect / wgetpaste.diff
Last active June 1, 2021 12:12
Patch that adds XDG dirs to the default wgetpaste config locations.
735c735
< for f in {/etc/,~/.}wgetpaste{.d/*,}.conf; do
---
> for f in {/etc/,~/.}wgetpaste{.d/*,}.conf; do
739a740,747
> # xdg locations override everything else
> if [[ -n "$XDG_CONFIG_HOME" ]]; then
> for f in $XDG_CONFIG_HOME/{wgetpaste/,wgetpaste/.,.,}wgetpaste{.d/*,}.conf; do
> if [[ -f $f ]]; then
> source "$f" || die "Failed to source $f"
@bynect
bynect / memswap.h
Last active August 23, 2021 00:57
Memswap implementation in ISO C.
#ifndef MEMSWAP_H
#define MEMSWAP_H
static inline void
memswap(void *restrict aptr, void *restrict bptr, size_t len)
{
register unsigned char *a = aptr;
register unsigned char *b = bptr;
register unsigned char t;