Skip to content

Instantly share code, notes, and snippets.

@tybl
tybl / string_split_benchmarking.cpp
Created April 15, 2022 22:56
string_split benchmarking
#include <string_view>
#include <algorithm>
struct StringRange {
char const* begin;
char const* end;
};
// uses string::find_first_of
std::vector<std::string>
@tybl
tybl / gist:5dc167b4a6408a8e0dee9bb3df67a54f
Created July 24, 2019 19:36
include-what-you-use/issues/670 valgrind dump
==13438== Memcheck, a memory error detector
==13438== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==13438== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
==13438== Command: include-what-you-use -Dlibledger_EXPORTS -I ../lib/utfcpp/v2_0/source/ -I ../build -DNDEBUG -fPIC -std=c++11 -o CMakeFiles/libledger.dir/filters.cc.o -c ../src/filters.cc
==13438==
==13438== Invalid read of size 8
==13438== at 0x99A71DB: clang::Sema::PushOnScopeChains(clang::NamedDecl*, clang::Scope*, bool) (in /usr/lib/libclangSema.so.8)
==13438== by 0x99C9359: clang::Sema::LazilyCreateBuiltin(clang::IdentifierInfo*, unsigned int, clang::Scope*, bool, clang::SourceLocation) (in /usr/lib/libclangSema.so.8)
==13438== by 0x9CC6406: ??? (in /usr/lib/libclangSema.so.8)
==13438== by 0x9CDE4BA: clang::Sema::LookupName(clang::LookupResult&, clang::Scope*, bool) (in /usr/lib/libclangSema.so.8)
@tybl
tybl / budget.ledger
Created May 27, 2017 14:57
YNAB budgeting with ledger-cli
; This is a simple method of maintaining a budget using
; double-entry accounting software.
; Usually, double-entry accounting keeps track of
; assets, liabilities, income, and expenses. However,
; income/expense categories are different than budget
; categories. For one thing, income/expense categories
; continually grow, where budget categories tend to rise
; and fall. I decided to replace tracking my income/
; expenses with tracking my budget.
@tybl
tybl / gist:e2121311cf5d940c2cc2
Last active August 29, 2015 14:04
Rust struct for calculating the running average(mean)
use std::num::{ zero, one };
struct Mean {
mean: f64,
count: u64,
}
impl Mean {
fn consider(&mut self, other: f64) {
self.count = self.count + one();