Skip to content

Instantly share code, notes, and snippets.

View wmerfalen's full-sized avatar
⚒️
never stop

William Merfalen wmerfalen

⚒️
never stop
View GitHub Profile

My Hobby Projects

C/C++ projects

knockd

knockd is a simple port knocking daemon that utilizes libpcap to capture packets before it reaches the firewall (i.e.: iptables)

@wmerfalen
wmerfalen / license.h
Created December 3, 2023 03:35
example license based on zlib (https://www.zlib.net/zlib_license.html)
/*
xorlock -- a top-down 2D shooter inspired by Nuclear Throne and Diablo II+III
version 0.0.1-beta, December 2nd, 2023
Copyright (C) 2022-2023 William Merfalen
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
@wmerfalen
wmerfalen / rand-c.sh
Created November 11, 2023 06:17
random hex-encoded C string
dd if=/dev/urandom bs=32 count=5 skip=32 2>/dev/null | hexdump | cut -d' ' -f2- | sed -E 's|\s([a-f0-9]{2})([a-f0-9]{2})|\\x\1\\x\2|gi' | sed -E 's|^([a-f0-9]{2})([a-f0-9]{2})|\\x\1\\x\2|' | head -n 2 | tr -d '[:space:]'
@wmerfalen
wmerfalen / rand32.sh
Created November 8, 2023 21:34
Generate 32 random alphanumeric bytes
dd if=/dev/urandom count=32 bs=8 2>/dev/null | base64 | tr -d '[:punct:]' | head -c 32 | tr -d '[:space:]'
This file has been truncated, but you can view the full file.
@wmerfalen
wmerfalen / vanilla-class.js
Created August 22, 2023 22:41
[vanilla JS]: Add a class to a given element using
let element = document.querySelector("selector")
element.classList.add("class")
@wmerfalen
wmerfalen / debounce.js
Created August 22, 2023 10:07
Javascript Debounce
// Source: https://www.freecodecamp.org/news/javascript-debounce-example/
function debounce(func, timeout = 300){
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => { func.apply(this, args); }, timeout);
};
}
function saveInput(){
console.log('Saving data');
@wmerfalen
wmerfalen / host-to-network.js
Created April 28, 2023 09:14
host to network conversion functions
/**
I copied this from: https://github.com/mattcg/network-byte-order/blob/master/lib/index.js
Go give that repo a star
*/
/* Copyright 2010 Membase, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@wmerfalen
wmerfalen / tokenize.js
Last active February 21, 2023 01:16
Turn url search params into an associative array
const tokenize = (__in_url=null) => {
let url = window.location.href;
if(__in_url !== null){
url = __in_url;
}
return (new URLSearchParams((new URL(url)).search));
};
/**
* Example:
/usr/bin/astyle -A2 -t -xn -xc -xl -xk -xV -C -xG -S -K -N -M80 -U -W1 -j --suffix=none $@