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/sh | |
# usage: ./tabless INPUT_FILE | |
# | |
# INPUT_FILE is expected to be a text file containing lines like the following: | |
# | |
# 23 column-1-name -554.23 column-2-name ... | |
# | |
# The output will be a `less` session of the numbers only, tabulated, but with | |
# a header of column names pinned to the top line, e.g. |
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 <atomic> | |
#include <memory> | |
#include <utility> | |
template <typename T> | |
class LockFreeStack { | |
private: | |
struct Node { | |
T value; | |
Node *next; |
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
int count( | |
std::unordered_map<std::int64_t, int>& memo, | |
const std::vector<int>& denominations, | |
int coin_index, | |
int amount) { | |
if (coin_index < 0 || amount < 0) { | |
return 0; | |
} | |
if (amount == 0) { |
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 <optional> | |
#include <tuple> | |
struct TupleHasher { | |
template <typename... Values> | |
std::size_t operator()(const std::tuple<Values...>& key) const { | |
std::size_t seed = 0; | |
std::apply(HashAppend{seed}, key); | |
return seed; | |
} |
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 <string> | |
#include <vector> | |
std::string longest_palindromic_substring(const std::string& text) { | |
const int n = text.size(); | |
if (n < 2) { | |
return text; | |
} | |
std::vector<bool> grandparent(n, true); | |
std::vector<bool> parent(n - 1, true); |
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
"""re_match - sqlite3 regular expression pattern extraction function | |
The SQL function `re_match(pattern, subject)` returns the first subgroup match in | |
`subject` if `subject` matches `pattern`. It returns `subject` if it matches but | |
has no subgroups. It returns null if it doesn't match. | |
`re_match(pattern, subject, group)` allows for the extraction of some other | |
subgroup, which can be a 1-based index or a name. | |
`re_matchi` is `re_match` but case-insensitive. |
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 <filesystem> | |
#include <iomanip> | |
#include <iostream> | |
#include <iterator> | |
#include <string> | |
#include <vector> | |
namespace fs = std::filesystem; | |
// Return whether the specified `path` ends with the specified `suffix`. |
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/sh | |
# Forward command line arguments to "docker compose up", | |
# but also prevent ctrl+c from being handled by "docker compose up". | |
# Instead, handle it here by calling "docker compose down". | |
# This way, containers and networks created by docker compose will be | |
# cleaned up in workflows where you bring down services via ctrl+c. | |
# The default handling by docker compose does bring down services | |
# but does not remove networks and containers. |
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
// Based off of a Go example in <https://research.swtch.com/glob> accessed | |
// February 3, 2022. | |
function match(pattern, subject) { | |
px = 0 // [p]attern inde[x] | |
sx = 0 // [s]ubject inde[x] | |
nextPx = 0 | |
nextSx = 0 | |
while (px < pattern.length || sx < subject.length) { | |
if (px < pattern.length) { |
NewerOlder