Skip to content

Instantly share code, notes, and snippets.

View sneppy's full-sized avatar

Andrea Mecchia sneppy

  • Arm Ltd.
View GitHub Profile
@sneppy
sneppy / generator.hpp
Created April 10, 2022 14:55
Example of a Python-like generator implemented using C++20 coroutines
/**
* @file generator.hpp
* @author andrea.mecchia@mail.polimi.it
* @brief Example of a Python-like generator implemented
* using C++20 coroutines
* @date 2022-04-10
*
* @copyright Copyright (c) 2022 Andrea Mecchia
*
* C++20 coroutines allow us to create Python-like
@sneppy
sneppy / main.cpp
Created February 10, 2022 22:03
A simple non-compliant XML parser implementation
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
@sneppy
sneppy / message.h
Created January 30, 2022 00:51
C++ inter-thread message system
#pragma once
#include <utility>
#include <variant>
#include <mutex>
#include <condition_variable>
namespace
{
@sneppy
sneppy / main.c
Last active September 25, 2021 16:03
Example of a memory pool implementation in C with same size blocks
int main()
{
memory_pool_create_info_t info = {
.block_size = 1024,
.block_alignment = 32,
.num_blocks = 128
};
memory_pool_t* pool = memory_pool_create(&info);
@sneppy
sneppy / .gitignore
Last active September 24, 2021 09:45
VS Code settings for building, testing and debugging C/C++ projects
*.a
*.so
*.so.?*
*.dll
*.exe
*.dylib
*.cmake
!/cmake/*.cmake
!/test/AssemblyTests.cmake
*~
@sneppy
sneppy / format.js
Created April 27, 2020 19:06
sprintf for JavaScript
/**
*
*/
String.prototype.format = function formatString(...subs) {
// String tag functions
// @ref https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
const formatter = (strings, ...keys) => {
return (...values) => {
@sneppy
sneppy / chain.sql
Last active April 18, 2020 09:55
PonyORM
---------------------------------------------
-- This procedure takes as input the hash of
-- a post commit and returns the chain of
-- parent commits up to the root commit (i.e.
-- NULL parent)
---------------------------------------------
-- Drop old procedure
drop procedure if exists commit_chain;
@sneppy
sneppy / quicksort.h
Last active January 17, 2020 17:25
A C++ quicksort implementation that requires only a forward iterator to work
template<typename T>
struct RemoveReference
{
using Type = T;
};
template<typename T> struct RemoveReference<T&> { using Type = T; };
template<typename T>
inline void swap(T & a, T & b)
@sneppy
sneppy / tuple.h
Last active November 7, 2019 15:30
A C++ replica of Python's tuple
/**
* @copyright
*/
#pragma once
/**
* Compute min between two numbers
*/
template<typename T>
# Variables
# ^^^^^^^^^
# FbxSdk_FOUND
# FbxSdk_INCLUDE_DIR
# FbxSdk_LIBRARIES
# Find root dir
find_path(FBXSDK_ROOT_DIR
NAMES