This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Sort Beancount Entries by meta['time'] | |
Although beancount says that time is meaningless, there are situations | |
where an account that should not be negative may have a negative balance | |
at some point because transfers that occurred on the same day are | |
scheduled later and spending records are scheduled earlier. | |
This is not a big deal, but it is a bit odd. | |
2021-10-01 balance Assets:Cash 500 USD |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
auto p = std::remove_if( | |
std::begin(a), std::end(a), [](const auto& e) { return e.seleted(); }); | |
a.erase(p, std::end(a)) | |
// in C++20 | |
auto p = ranges::remove_if(a, &E::selected); | |
a.erase(p, std::end(a)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// base case | |
template <class... Types, size_t n, size_t... indices> | |
std::tuple<Types...> toAnyTuple( | |
std::array<std::any, n> const& arr, | |
std::index_sequence<indices...>) { | |
return std::make_tuple(std::any_cast<Types&>(arr[indices])...); | |
} | |
// general case | |
template < | |
class... Types, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
effs=(0 1 2 7 9) | |
effs2=(0 1 2 3 4 5 6 8) | |
for eff in "${effs[@]}" ; do | |
for i in {30..37} ; do | |
for j in {40..47} ; do | |
ansi_eff="${eff};${i};${j}m" | |
printf "\033[${ansi_eff} ${ansi_eff} \033[0m" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <fstream> | |
#include <sstream> | |
using namespace std; | |
int main(int argc, char *argv[]) { | |
string input_filename = argv[1]; | |
ifstream input_stream; | |
input_stream.open(input_filename); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <complex> | |
#include <iostream> | |
#include <valarray> | |
#include <vector> | |
using namespace std; | |
const double PI = 3.141592653589793238460; | |
typedef std::complex<double> Complex; | |
typedef std::valarray<Complex> CArray; |