Skip to content

Instantly share code, notes, and snippets.

@zackgalbreath
zackgalbreath / CMakeLists.txt
Last active October 30, 2022 12:00
gRPC add_subdirectory example
cmake_minimum_required(VERSION 3.14...3.16)
project(HelloGRPC)
# Clone gRPC at configure time.
include(FetchContent)
FetchContent_Declare(
grpc
GIT_REPOSITORY https://github.com/grpc/grpc.git
GIT_TAG v1.25.0
)
@gcatlin
gcatlin / sdl-metal-example.m
Last active February 24, 2025 15:11
Minimal C SDL2 Metal example
//
// cc sdl-metal-example.m `sdl2-config --cflags --libs` -framework Metal -framework QuartzCore && ./a.out
//
#include <SDL.h>
#import <Metal/Metal.h>
#import <QuartzCore/CAMetalLayer.h>
int main (int argc, char *args[])
{
SDL_SetHint(SDL_HINT_RENDER_DRIVER, "metal");
@vedantroy
vedantroy / client.cpp
Last active April 8, 2024 22:26
A C++ Client That Sends Data Over TLS Using OpenSSL
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <resolv.h>
#include <netdb.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
//Not sure what headers are needed or not
//This code (theoretically) writes "Hello World, 123" to a socket over a secure TLS connection
@chinmaygarde
chinmaygarde / FlutterEmbedderGLFW.cc
Last active March 27, 2025 01:57
Flutter Embedder API Example (GLFW with OpenGL)
#include <assert.h>
#include <chrono>
#include <embedder.h>
#include <glfw3.h>
#include <iostream>
static_assert(FLUTTER_ENGINE_VERSION == 1, "");
static const size_t kInitialWindowWidth = 800;
@vmrob
vmrob / channel.cpp
Last active March 29, 2021 23:40
Go channels in C++
#include <future>
#include <iostream>
#include <thread>
#include <queue>
template <typename T>
class concurrent_queue {
private:
std::queue<T> _queue;
std::mutex _mutex;
@ciembor
ciembor / gist:1494530
Last active September 22, 2025 05:37
RGB to HSL and HSL to RGB conversion functions
/*
* Copyright 2011 Maciej Ciemborowicz
* https://maciej-ciemborowicz.eu
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*