GeezerVison is showing gist.github.com — fDero’s gists
Instantly share code, notes, and snippets.
The following is an implementation of a general-purpose flexible and extendible framework for
measurement-units in C++23. The core idea is that the user can assign to a variable of type
Unit<...> values of which the type is a different unit of measurement, as long as the two
variables share a dimension (e.g. Kilometers, Miles, Meters, Yards, they all represent length).
#include "units.hpp"
#include "examples.hpp"
This gist hosts a simple python script that can be used to retrieve a google oauth 2.0 access token given a
client-secret generated via google cloud. You can use a client-secret for a desktop-app, since it makes it easier
to generate such secret, especially if you don't have a working frontend just yet.
You can use this setup to test your backend API against real google tokens and eventually go forward with the development
in case the frontend is not ready yet at the time you are creating the authentication endpoints.
The following is an implementation for an array-style wrapper around C++ parameter packs.
using Pack2 = ParameterPack<bool, float>;
using Pack3 = Pack2::Append<std::string>;
using Pair = typename Pack2::Instantiate<std::pair>;
Pair p = std::pair<bool, float>(true, 3.14);
Partial Functions Application in C++
The following is an implementation of haskell-style function application in pure C++.
Function<int, int>::Returning<int> add = [](int a, int b){ return a + b; };
Function<int>::Returning<int> add4 = add(4);
int full_application = add(4, 2);
int partial_application = add4(2);
I've written this script to download all the music scores from https://www.mindformusic.com/bigband.
I just tought it was cool.
for x in $(seq 0 25 875); do
curl -s "https://www.mindformusic.com/bigband?start=$x" \
| grep "/bigband/" \
| grep -oP '(?<=href=")[^"]*' \
Sudo command on Windows (Powershell)
If you ever find yourself working in powershell, you know the pain of having to run a new
terminal as an administrator just to run a command or two. You probably dream about having some
sort of utility just like sudo on linux but for windows.
First things first, i gotta tell you, big brains at Microsoft HQ have your back, because now, if you
go in Settings > System > For Developers you can see Enable sudo
Note If you want to follow along, use inline mode in the drop-down menu.
Java implementation of a Stack-Machine
A stack machine is a computer processor or a virtual machine in which the primary interaction
is moving short-lived temporary values to and from a push down stack. The use of a stack significantly
reduces the required number of processor registers. Stack machines extend push-down automata with additional
load/store operations or multiple stacks and hence are Turing-complete.
I implemented a stack-machine in java with the intent of evaluating arithmetic expressions
assembled at run-time using the following API:
An over-engineered and hyper-optimized golang implementation of a function that computes the Nth fibonacci number using
arbitrary precision integers.
With arbitrary precision aritmethic comes the huge performance impact of
non-constant time arithmetic operations.
Example of a googletest/gtest-style macro
The following code shows how to create a TEST macro that works like the following:
TEST(MySuccessfulTestCase) {
printf("OK!!");
}
TEST(MyFailedTestCase) {
Writers First R/W Mutex in Go
This gist showcases how we can create a wrapper around the sync.RWMutex type to create our own version, with the specific intent
of making write-locks having strict precedence over read-locks.
This is achieved via the use of an internal atomic counter of type atomic.Int64 that keeps track of pending write-locks,
and a sync.Cond condition variable that is used by the RLock() method to wait until no write-locks are pending anymore.
|