Skip to content

Instantly share code, notes, and snippets.

View hgiesel's full-sized avatar
🐇
Focusing

Henrik Giesel hgiesel

🐇
Focusing
  • Frankfurt, Germany
View GitHub Profile
interface TaggedHookCallback<T> {
type: "hook";
callback: HookCallback<T>;
}
type FilterCallback<T, U> = (input: T) => Promise<U> | U;
interface TaggedFilterCallback<T, U> {
type: "filter";
@hgiesel
hgiesel / AnkiMultipleChoiceBackTemplate.html
Last active July 17, 2019 18:50
A Multiple Choice Template for Anki Cards
<script>
// MULTIPLE CHOICE BACK TEMPLATE v1.3 {{{
// https://gist.github.com/hgiesel/2e8361afccca5713414a6a4ee66b7ece
if (window.Persistence && Persistence.isAvailable() && Persistence.getItem("multipleChoiceSettings")) {
var settings = Persistence.getItem("multipleChoiceSettings")
var query = settings.query
var colors = settings.colors
var fieldPadding = settings.fieldPadding
@hgiesel
hgiesel / cc.md
Last active November 4, 2016 03:12
Programming Links and Insights

Phases

Preprocessing phase
  • basic source character set (no `$@) translated to universal character name (\u + \U)
  • (trigraph sequences)
  • <newline> at the end of the line are removed (single pass)
  • decomposed into comments and preprocessing tokens:
    • header names, identifiers, numbers, literals, etc.
    • operators + punctuators
  • transformations inside double quotes are reverted
@hgiesel
hgiesel / in_between.c
Last active June 29, 2016 00:26
Calculating if a point (x,y) is in between two other points on a plane
struct point {
int x;
int y;
}
void is_between(struct point the_point, struct point a, struct point b) {
int cross_product = (the_point.y - b.y) * (a.x - b.x) - (the_point.x - b.x) * (a.y - b.y);
if (abs(cross_product) != 0) {
return false;
@hgiesel
hgiesel / hello_world.s
Last active April 16, 2016 22:17
x86_64 syscall in GAS at&t syntax on OS X
.globl start
.cstring
str:
.asciz "Hello World!\n"
str_length:
.set str_lngth, .-str
.text
start:
@hgiesel
hgiesel / doublequote_op.cc
Last active June 29, 2016 00:24
Examples of useful C++ snippets
#include <iostream>
#include <string>
class Yen {
int _amount;
public:
Yen(size_t amount): _amount(amount) { /* */ }
friend auto operator<< (std::ostream& os, const Yen& yen) -> std::ostream& {
@hgiesel
hgiesel / get_libdir.sh
Last active June 29, 2016 00:17
Useful Bash snippets
#!/usr/bin/env bash
DIR="$(builtin cd "$(dirname "${BASH_SOURCE}" && pwd)" # doesn't actually cd into directory
FILE="${DIR}/$(basename "${BASH_SOURCE}")"
SYMLINKED_FILE=$(readlink "${FILE}")
[[ -n "${SYMLINKED_FILE}" ]] && LIBDIR="$(dirname "${SYMLINKED_FILE}")" || LIBDIR=${DIR}
echo "DIR: $DIR"
echo "FILE: $FILE"
echo "SYMLINKED_FILE: $SYMLINKED_FILE"
echo "LIBDIR: $LIBDIR"