Skip to content

Instantly share code, notes, and snippets.

@mattvchandler
mattvchandler / tinycsv.cpp
Last active August 12, 2019 22:31
Tiny CSV - CSV pretty printer that will fit on a business card or in a QR code
#include<string>//Tiny CSV pretty-print
#include<vector>//Matthew Chandler
#include<cstdio>//mattvchandler@gmail
#define E feof(f)//©2019 by MIT license
#define G c=getc(f);//build w/ c++17
#define Z size()//./tinycsv foo.csv
using namespace std;using I=int;using S=
string;pair<S,I>p(FILE*f){I q=0,c;S w;
while(1){G if(c==EOF&&!E)throw 0;if(c==
'"'){if(q){G if(c==','||c=='\n'||c=='\r'
@mattvchandler
mattvchandler / title_case.c
Last active November 4, 2015 19:04
Title case library
// title_case.c
// Attempt at proper title casing algorithm
// The basic method is to 1st load a dictionary of exceptions
// when given a string, we will look up each word in the dictionary.
// If found, we will use the capitalization from the dictionary file
// otherwise, all words start with a capitals, and the rest are lowercase
// the 1st letter of the 1st and last words in the string are always capitalized
// only works for ascii text