This file contains 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
create or replace function jsonb_deep_key_value (j jsonb) | |
returns table (key text, value jsonb) | |
as $$ | |
with recursive t(key, value) as ( | |
select | |
jj.key, | |
jj.value | |
from | |
jsonb_each(jsonb_build_object('', j)) as jj | |
union all ( |
This file contains 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
# Produce a unified requirements.txt (no guarantees this comparison works properly for all versioning cases) | |
cat requirements.txt <(pip freeze) | awk 'BEGIN { FS="=="; OFS="==" } { if (V[tolower($1)] != "") { if ($2 != V[tolower($1)]) { print $1, $2 } else { print $1, V[tolower($1)] } } else { V[tolower($1)]=$2 } }' | |
# Produce a diff for manual inspection | |
cat requirements.txt <(pip freeze) | awk 'BEGIN { FS="=="; OFS="==" } { if (V[tolower($1)] != "") { if ($2 != V[tolower($1)]) { print "- "$1, V[tolower($1)]; print "+ "$1, $2 } else { print " "$1, $2 } } else { V[tolower($1)]=$2 } }' |
This file contains 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
# From https://gist.github.com/u8sand/b7f9f146c6349316e324d2261e5fd1ac | |
def inject(ctx=globals()): | |
''' [NOT SECURE]: Exposes a set of python functions as a python command-line application. | |
All functions exposed with docstring, argument names, defaults, annotations, etc... | |
The first line of a docstring is treated as the description; and the command-line spec is | |
automatically converted. | |
Usage: add the following to the bottom of your script | |
``` |
This file contains 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
#!/usr/bin/env python3 | |
import os | |
import sys | |
import glob | |
import imagehash | |
from PIL import Image | |
from functools import reduce | |
from itertools import chain |
This file contains 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
import React from 'react' | |
import fitty from 'fitty' | |
class Fitty extends React.Component { | |
fitty_props = ['minSize', 'maxSize', 'multiLine'] | |
constructor(props) { | |
super(props) | |
this.init = this.init.bind(this) |
This file contains 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
FROM nginx | |
RUN rm /etc/nginx/nginx.conf | |
ADD ./setup.sh /setup.sh | |
ENTRYPOINT [ "/bin/bash", "/setup.sh" ] | |
CMD [ "nginx", "-g", "daemon off;" ] |
This file contains 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
export function range(start, end) { | |
if (end === undefined) { | |
end = start | |
start = 0 | |
} | |
function *_range() { | |
for(let i = start; i < end; i++) { | |
yield i | |
} |
This file contains 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
import { matrix_flatten, matrix_slice, slice } from './matrix' | |
import { range } from './range' | |
export function count_first_na(L) { | |
for (let i = 0; i < L.length; i++) { | |
if (L[i] != null) | |
return i | |
} | |
throw new Error('NaNs not identified') | |
} |
This file contains 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
export function slice(left, right) { | |
return { | |
left, | |
right, | |
} | |
} | |
export function resolve_slice(s, l) { | |
if (s === null) { | |
return slice(0, l) |
This file contains 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
var test = require('tape') | |
var assert = require('assert') | |
/** | |
* Convert tape tests into mocha assertions! | |
* | |
* @example | |
* tape_it('my mocha tape test assertion', function (test) { | |
* test('my tape test', function (t) { | |
* t.equal(1, 1) |