Skip to content

Instantly share code, notes, and snippets.

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

r-lyeh-archived

View GitHub Profile
@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
/* Mike F */
#include <stdint.h>
void *memalign( int align, size_t size ) {
void *mem = malloc( size + (align-1) + sizeof(void*) );
if(!mem) return 0;
char *amem = ((char*)mem) + sizeof(void*);
amem += (align - ((uintptr_t)amem & (align - 1)) & (align-1));
((void**)amem)[-1] = mem;
/*
Testing read file speed for the three read functions from
http://cpp.indi.frih.net/blog/2014/09/how-to-read-an-entire-file-into-memory-in-cpp/
compile with -std=c++11
*/
#include <type_traits>
#include <ostream>
#include <sstream>
// [src] https://github.com/apfeltee/cpp11-sprintf
#include <iostream>
#include <sstream>
#include <string>
std::string fmt( const char *format ) {
return format ? format : "";
}
#include <string>
#include <iostream>
#include <utility>
void internal_func(const std::string& s)
{
std::cout << s << '\n';
}
template <typename ... T>
@r-lyeh-archived
r-lyeh-archived / variant2.hpp
Created April 19, 2016 11:47
another small variant class
// another small variant class
// - rlyeh, public domain
#pragma once
#include <string>
#include <sstream>
template< typename T >
inline T as( const std::string &self ) {
T t;
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main( int argc, const char **argv ) {
if( argc >= 3 ) {
float cycle = atof(argv[1]);
float distance = atof(argv[2]);
float excess = fmodf( distance, cycle );
@r-lyeh-archived
r-lyeh-archived / git-tips.md
Last active March 28, 2016 08:54
git-tips

Git tree command

git config --global alias.tree "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"

git tree
* c3aee36 - (HEAD -> master, tag: DAY01, origin/master, origin/HEAD) '' (2 minutes ago) <r-lyeh>
* 5c978e9 - Initial commit (4 minutes ago) <r-lyeh>