Skip to content

Instantly share code, notes, and snippets.

View pniedzielski's full-sized avatar

Patrick M. Niedzielski pniedzielski

View GitHub Profile
@pniedzielski
pniedzielski / etcsl.org
Created November 1, 2020 17:45
How to download the ETCSL Corpus

ETCSL Corpus

I can never remember how to download the ETCSL corpus, because it’s hosted on the the Oxford Text Archive (DOI: 20.500.12024/2518). Here are the instructions to download a local copy to the current directory.

@pniedzielski
pniedzielski / keybase.md
Created March 9, 2016 19:21
Keybase.io Ownership Proof

Keybase proof

I hereby claim:

  • I am pniedzielski on github.
  • I am pniedzielski (https://keybase.io/pniedzielski) on keybase.
  • I have a public key whose fingerprint is A66F 5099 CC43 0B02 5B53 D0B9 7F2A 9552 DEBF A176

To claim this, I am signing this object:

@pniedzielski
pniedzielski / variant-generator.cpp
Last active November 3, 2020 07:10
Type-safe generation of variant<Ts...> in C++
// Say we want something that generates a T when it is called with
// operator():
template <typename G, typename T>
concept bool Generator = requires (G g) {
{ g() } -> T
};
// For instance, this is a Generator of int
int gimmeRandomInt() { return rand(); }
@pniedzielski
pniedzielski / c++17-crtp-variadic-mixins.cpp
Last active November 3, 2020 07:11
Strong typedef / member functions on built-in types (C++17)
// Transcribed (with simple modifications and added comments) from _Fundamentals of Type-Dependent Code Reuse in C++_ presentation by Mark Isaacson at NDC 2015
template <typename T, template <typename> class... Mixins>
struct Mixer : public Mixins< Mixer<T, Mixins...> >... {
// N4477 Operator Dot (R2), on track for C++17
T& operator.() { return value; }
private:
T value;
};
template <typename T>
/* We have three ways of importing the literals in something designed
like the standard library: */
void my_function() {
/* Means "now all of foo is the most important thing in this
function" -> implies shift from what was most important outside
this function */
using namespace foo;
// OR
/* Means "now the user-defined literals from foo are important" ->
implies everything else is like outer scope