Skip to content

Instantly share code, notes, and snippets.

View wtrsltnk's full-sized avatar

Wouter Saaltink wtrsltnk

View GitHub Profile
@wtrsltnk
wtrsltnk / shout-cast.cs
Created May 1, 2024 17:57
An example console app in C# looping a ogg file to a Shout cast server
using System.Net.Sockets;
using System.Text;
namespace ConsoleApp1
{
internal class Program
{
private const string clientId = "source";
private const string clientSecret = "hackme";
private const string clientName = "😂 stream";
@wtrsltnk
wtrsltnk / Dependencies.cmake
Last active March 7, 2022 21:11
Adding libcurl dependancy with cmake and CPM
include(cmake/CPM.cmake)
CPMAddPackage(
NAME mbedtls
GITHUB_REPOSITORY "ARMmbed/mbedtls"
GIT_TAG "v3.1.0"
OPTIONS
"ENABLE_PROGRAMS OFF"
"ENABLE_TESTING OFF"
)
@wtrsltnk
wtrsltnk / event-delegate-handler.cpp
Last active January 9, 2022 21:59
Event delegate handler in c++
#include <functional>
#include <iostream>
#include <vector>
template <class TArgs>
class Delegate
{
std::vector<std::function<void(const TArgs &)>> _handlers;
public:
@wtrsltnk
wtrsltnk / cpp-dependancy-injection.cpp
Created April 10, 2021 13:44
This is an example of how I think DI can work in c++. Due to missing reflection, you still need to construct the objects yourself with a lambda passed to the Register<T>() method..
#include <functional>
#include <map>
#include <memory>
#include <string>
#include <typeindex>
#include <typeinfo>
typedef void* Object;
typedef std::function<Object(class ServiceCollection&)> ServiceBuilder;
@wtrsltnk
wtrsltnk / repo-from-template.ps1
Created May 6, 2020 11:32
Create new repository from template repository on disk
$TemplateRepoName = $args[0]
if ($args.count -le 1) {
$NewRepoName = Read-Host -Prompt 'What is the name of the new repository?'
} else {
$NewRepoName = $args[1]
}
$TemplateName = Split-Path $TemplateRepoName -leaf
@wtrsltnk
wtrsltnk / cs_property_in.cpp
Last active April 25, 2020 23:16
C# Property in C++
#include <functional>
#include <iostream>
#include <string>
template<class T>
class Property
{
T _value;
std::function<T (void)> _get;
std::function<void(const T&)> _set;
@wtrsltnk
wtrsltnk / httpsclientrequest.cpp
Last active April 3, 2021 19:05
How to do a https request in win32
#define WIN32_LEAN_AND_MEAN 1
#include <windows.h>
#include <wininet.h>
#include <stdio.h>
int main()
{
static HINTERNET hInternet;
hInternet = InternetOpenA("wininet-test", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);