Skip to content

Instantly share code, notes, and snippets.

View royvandam's full-sized avatar
🚀

Roy van Dam royvandam

🚀
View GitHub Profile
@royvandam
royvandam / extract_includes.go
Created March 3, 2023 14:49
Regex based C/C++ include parser in Golang capable of dealing with comments
package main
import (
"strings"
"bufio"
"regexp"
"fmt"
)
const test_data = `
@royvandam
royvandam / poly.go
Last active August 2, 2022 21:14
Golang "inheritance" by composition and polymorphic classes
package main
import (
"fmt"
"math"
)
type (
Shape interface {
GetCoords() (float64, float64)
@royvandam
royvandam / exception.cc
Last active April 9, 2021 21:44
Simple C++ global exception handling for targets with -fno-exceptions enabled
#include <functional>
class Exception {
public:
using StringType = const char*;
protected:
StringType _what;
StringType _file;
std::size_t _line;
@royvandam
royvandam / path.cc
Created October 30, 2020 16:50
O(n) time / O(1) memory C++ std::string_view based path iterator
#include <string_view>
#include <iostream>
using namespace std::literals;
struct Path {
class Iterator {
protected:
std::string_view _path;
char _separator;
@royvandam
royvandam / math.hpp
Created October 30, 2020 07:40
Float comparison
#pragma once
#include <cfloat>
#include <cmath>
#include <cstdlib>
/**
* @brief Math related utility functions
*/
namespace Math {
@royvandam
royvandam / pingscan.sh
Created May 28, 2020 07:27
Pure SH ping host network scan
for i in $(seq 1 254); do ping -w1 -c1 10.0.0.$i > /dev/null; if test $? -eq 0; then echo $i; fi done
@royvandam
royvandam / laptop.pub
Created May 27, 2020 19:10
Public Keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDOh/CU9vQ2cQR8j7K4TIDJVns6T+im24OpuO8F+aPHJS7VOTaPwbHZZT+i+0hqzVRpwNceZPezIfckIlHH19YMQMu9+KcUEyBZrnaqvQZM8mSe/oXebv1L/XaZpc6y5OhV/o4SzScxlnLMZFjlgyYgVLWUJ8tCtPl2TL+MuCBt+rpa+HOZhbkbAKi992axQd/pmGlkGigpoKiY11ZIXDsWhbssoe76KFzg+x3G/k2Uds4oYt216rYia3WHcikk7GzDmAY6Svws31Q/yvl+RJByVE35cfrkpNTPZGP5LUUH8JhvjF5V0kNqrR2WUlxGtlLHVla+JvFfH3ykI38NFqMKYqhZ4ESMofAIXjmeRglC62DfuOl3ogkmJXinWBTraXLOKrGlCA7BpMf2q7vBFk7+Oa/T9hn71+E8E+h/FeWPZwhV58pUpnnvOFQDn2EpBPtSNpnMH4UZ0b3/rZKEX3bf4OemqPfbxjAofASLCZRvhUardgnUuKwxlzRPP2eiY4qVx9P5oZVAJH4sMypLf8c/xRfqhMs/r22aaI5ynQnRuk1kgGTgLaXYV6o5F9ARB8QLD0rps+7NSKVN6r3eRnTqk+nEiVqPq0cLze5aUVFNTxr8/BJq1KDSZQ0PSUZD9EtgMJnuxf3WFiE8T6eM/BKu6sB1TtJHfAoHCr5x0pT4ew== roy@clnt
@royvandam
royvandam / autossh.service
Created February 28, 2020 10:40
Auto-starting reverse SSH proxy using systemd service file
[Unit]
AssertPathExists=/home/${user}/.ssh/id_rsa
After=network.target
[Service]
User=${user}
WorkingDirectory=/
ExecStart=/usr/bin/ssh -vvv -N -T \
-R 0:localhost:22 \
-o PasswordAuthentication=no \
@royvandam
royvandam / array_view.hpp
Last active February 12, 2020 08:16
array_view<T> a C style pointer array wrapper class with bounds checking, similar to std::span which is introduced in C++20.
#pragma once
#include <algorithm>
#include <iterator>
#include <stdexcept>
template <typename T>
class ArrayView
{
public:
@royvandam
royvandam / main.go
Created August 2, 2018 07:42
Roles API test
package main
import (
"net/http"
"github.com/gorilla/mux"
"log"
"encoding/json"
)
type Role struct {