Skip to content

Instantly share code, notes, and snippets.

@lierdakil
lierdakil / fix-image-links.lua
Created November 8, 2018 08:17
Pandoc filter to (poorly) fix links to images when exporting to docx
@lierdakil
lierdakil / arrNd.hxx
Last active October 14, 2018 20:56
Minimal robust multidimensional array wrapper over std::vector in C++14
#include <vector>
#include <numeric>
#include <array>
template<class T, size_t Ndim> class arrNd {
const std::array<const size_t, Ndim> _size;
std::array<size_t, Ndim-1> _strides;
std::vector<T> _data;
T& get(std::array<size_t, Ndim> ix) const {
return const_cast<T&>(_data.at(
@lierdakil
lierdakil / filter.hs
Created July 10, 2018 06:59
Pandoc filter to replace internal links with page references
import Text.Pandoc.JSON
import Data.List
main :: IO ()
main = toJSONFilter myfilter
myfilter (Link _ text (url, _))
| '#':ref <- url
= Span nullAttr $
text <>
@lierdakil
lierdakil / gitlab-math.lua
Last active April 9, 2023 08:15
Pandoc filter to parse GitLab math
function Math(el)
if el.mathtype == "InlineMath" then
if el.text:sub(1,1) == '`' and el.text:sub(#el.text) == '`' then
local text = el.text:sub(2,#el.text-1)
return pandoc.Math(el.mathtype, text)
else
local cont = pandoc.read(el.text)
return { pandoc.Str("$") } .. cont.blocks[1].content .. { pandoc.Str("$") }
end
end
@lierdakil
lierdakil / generator.sh
Last active July 26, 2019 10:29
Proper, if limited, type for Function.bind
#!/bin/bash
max=10
end=""
t=" "
echo "interface Bind {"
echo "${t}<T extends (...args: any[]) => any>(this: T, thisArg: any): T$end"
for i in `seq 1 $max`; do
echo -n "${t}<T extends ("
@lierdakil
lierdakil / variadic.ts
Created April 20, 2018 07:28
Kinda-sorta variadic functions in TypeScript?
type SubsString<T extends (...args: any[]) => any> =
T extends (x1: infer U1,) => any ? (x1: U1,) => string:
T extends (x1: infer U1,x2: infer U2,) => any ? (x1: U1,x2: U2,) => string:
T extends (x1: infer U1,x2: infer U2,x3: infer U3,) => any ? (x1: U1,x2: U2,x3: U3,) => string:
T extends (x1: infer U1,x2: infer U2,x3: infer U3,x4: infer U4,) => any ? (x1: U1,x2: U2,x3: U3,x4: U4,) => string:
T extends (x1: infer U1,x2: infer U2,x3: infer U3,x4: infer U4,x5: infer U5,) => any ? (x1: U1,x2: U2,x3: U3,x4: U4,x5: U5,) => string:
T extends (x1: infer U1,x2: infer U2,x3: infer U3,x4: infer U4,x5: infer U5,x6: infer U6,) => any ? (x1: U1,x2: U2,x3: U3,x4: U4,x5: U5,x6: U6,) => string:
T extends (x1: infer U1,x2: infer U2,x3: infer U3,x4: infer U4,x5: infer U5,x6: infer U6,x7: infer U7,) => any ? (x1: U1,x2: U2,x3: U3,x4: U4,x5: U5,x6: U6,x7: U7,) => string:
T extends (x1: infer U1,x2: infer U2,x3: infer U3,x4: infer U4,x5: infer U5,x6: infer U6,x7: infer U7,x8: infer U8,) => any ? (x1: U1,x2: U2,x3: U3,x4: U4,x5:
@lierdakil
lierdakil / pandoc-crossref.yaml
Last active April 1, 2019 05:23
pandoc-crossref v0.4.0.0-alpha6 default meta settings
captionIndexTemplate: $$ri$$
captionTemplate: '$$title% $$$$i$$$$titleDelim$$$$t$$'
codeBlockCaptions: False
collectedCaptionDelim: ','
collectedCaptionItemDelim: '--'
collectedCaptionTemplate: $$i$$$$collectedCaptionItemDelim$$$$t$$
crossrefYaml: 'pandoc-crossref.yaml'
defaultSectionPrefix: sec
lastDelim: ','
linkReferences: False
diff --git a/dcraw.cc b/dcraw.cc
index 88c8068..c49d654 100644
--- a/dcraw.cc
+++ b/dcraw.cc
@@ -9242,7 +9242,7 @@ canon_a5:
if (make[0] == 'O') {
i = find_green (12, 32, 1188864, 3576832);
c = find_green (12, 32, 2383920, 2387016);
- if (abs(i) < abs(c)) {
+ if (i < c) {
==================== stack-7.10.yaml ====================
hasktags-0.69.4: test (suite: testsuite)
### Failure in: 21:testcase12.hs:0:these were not found
tests/Test.hs:39
expected: ["Bar","Baz"]
but got: []
Cases: 150 Tried: 150 Errors: 0 Failures: 1
hasktags-0.69.4: Test suite testsuite failed
@lierdakil
lierdakil / example.ts
Last active September 19, 2022 13:28
An example of Functor in TypeScript. You can run this on https://www.typescriptlang.org/play/
interface Functor<T> {
map<U>(f: (x: T) => U): Functor<U>
}
class Box<T> implements Functor<T> {
value: T
constructor(x: T) {
this.value = x
}
map<U>(f: (x: T) => U): Box<U> {