Skip to content

Instantly share code, notes, and snippets.

View nbougalis's full-sized avatar

Nik Bougalis nbougalis

View GitHub Profile
@nbougalis
nbougalis / keybase.md
Created November 4, 2019 23:51
keybase.md

Keybase proof

I hereby claim:

  • I am nbougalis on github.
  • I am nbougalis (https://keybase.io/nbougalis) on keybase.
  • I have a public key ASABGbvTm-VP1imIWqp7P5uF-zjz6f00r5MZOKsb7fY-Ygo

To claim this, I am signing this object:

@nbougalis
nbougalis / ratio.cpp
Last active June 6, 2020 20:15
std::ratio for amendments
// Example for comment in PR 3428: https://github.com/ripple/rippled/pull/3428
#include <iostream>
#include <ratio>
constexpr int oldN = 204;
constexpr int oldD = 256;
constexpr int newN = 80;
constexpr int newD = 100;
@nbougalis
nbougalis / with_lock.cpp
Created September 23, 2024 14:34
Given a lock and a callable, invokes the callable under a lock in an exception-safe manner and returns its result (if any).
// I wrote this little helper function while working on a disaster of a
// codebase with little to no locking. One of my main goals was to make
// it thread safe.
//
// I needed an easy to grab a lock, do some work (which could sometimes
// throw an exception) and then release the lock, but I did not want to
// have lock_guard objects littered in every part of the code.
#include <utility>
#include <type_traits>