Skip to content

Instantly share code, notes, and snippets.

View r-lyeh-archived's full-sized avatar

r-lyeh-archived

View GitHub Profile
// [src] https://github.com/apfeltee/cpp11-sprintf
#include <iostream>
#include <sstream>
#include <string>
std::string fmt( const char *format ) {
return format ? format : "";
}
@r-lyeh-archived
r-lyeh-archived / Unicode table
Created April 12, 2017 15:23 — forked from ivandrofly/Unicode table
Unicode table - List of most common Unicode characters *
Unicode table - List of most common Unicode characters *
* This summary list contains about 2000 characters for most common ocidental/latin languages and most printable symbols but not chinese, japanese, arab, archaic and some unprintable.
Contains character codes in HEX (hexadecimal), decimal number, name/description and corresponding printable symbol.
What is Unicode?
Unicode is a standard created to define letters of all languages ​​and characters such as punctuation and technical symbols. Today, UNICODE (UTF-8) is the most used character set encoding (used by almost 70% of websites, in 2013). The second most used character set is ISO-8859-1 (about 20% of websites), but this old encoding format is being replaced by Unicode.
How to identify the Unicode number for a character?
Type or paste a character:
@r-lyeh-archived
r-lyeh-archived / distance.cc
Created June 30, 2015 15:20
point-to-point distance algorithms survey
// point-to-point distance algorithms survey
// - rlyeh, public domain.
// possible output {
// manhattan_distance: 0.608632s. (result: 6)
// octagonal_distance: 0.651783s. (result: 3.52249)
// baptista_distance: 1.10458s. (result: 4.79492)
// baptista_distance_b: 1.09981s. (result: 4.64063)
// euclidean_distance: 1.25s. (result: 4.47214)
// euclidean_distance_fast: 1.03207s. (result: 4.5)
@r-lyeh-archived
r-lyeh-archived / vector_view.cpp
Created April 21, 2015 15:38
vector_view implementation based off the tech string_view spec
// vector_view class, based on code by James exjam https://github.com/exjam/string_view
// rlyeh, public domain
#pragma once
#include <vector>
#if defined(_MSC_VER) && _MSC_VER < 1900
#define constexpr
#define noexcept
#endif
@r-lyeh-archived
r-lyeh-archived / kdtree.h
Last active July 14, 2017 18:23
kdtree
/*=======================================================*\
* file: gb/graphics/containers/kdTree.h *
* author: Sharov "Zefick" Sergey zefick@mail.ru *
* date: 27.03.2011 *
* version: 1.0 *
\*=======================================================*/
#ifndef KDTREE_H
#define KDTREE_H
/*
Delta Compression by Glenn Fiedler.
This source code is placed in the public domain.
http://gafferongames.com/2015/03/14/the-networked-physics-data-compression-challenge/
*/
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <string.h>
@r-lyeh-archived
r-lyeh-archived / defer.hpp
Created October 2, 2015 19:40
defer c++11
// src: http://www.gingerbill.org/article/defer-in-cpp.html
// This code requires C++11 features such as move semantics
#pragma once
#include <functional>
namespace Impl
{
template <typename Func>
struct Defer
@r-lyeh-archived
r-lyeh-archived / makegit.bat
Created October 13, 2015 10:59
generate git info for C++ inclusion
:: generate git info for C++ inclusion
:: - rlyeh, public domain
git rev-list --count --first-parent HEAD > git.hpp
set /p REVISION=<git.hpp
git rev-parse --abbrev-ref HEAD > git.hpp
set /p BRANCH=<git.hpp
echo #pragma once > git.hpp
@r-lyeh-archived
r-lyeh-archived / xlsx.cc
Last active March 28, 2017 14:00
xlsx exporter (i18n, L10n, xlsx, ini)
// XLSX exporter v1.01. (tags: xlsx, ini, c++11, i18n, L10n)
// - rlyeh, public domain
// This tool exports given xlsx:
//
// ._______._____
// |sheet1 \ ... \
// |---------------------------------------------------
// 1| LABEL | NOTES | ENGLISH | SPANISH | ...
// |----------+----------+-----------+-----------+-----
// from PolyGlot master sheet 0.9 - CC1.0 licensed
// https://github.com/PolyglotGamedev/mastersheet/blob/master/PolyglotGamedev-Master.csv
enum {
comment,
enUS/*enGB*/,frFR,
esES/*esAR esMX*/,
deDE/*deCH deAT*/,
itIT/*itCH*/,
ptBR,ptPT,ruRU,elGR,trTR,daDK,noNB,svSE,nlNL,plPL,fiFI,jaJP,zhCN/* zhSG*/,zhTW/* zhHK zhMO*/,koKR,csCZ,huHU,roRO,thTH,bgBG,heIL