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/bash | |
find "$1" -name "*.pdf" | while read file; do | |
path=${file%/*} | |
basename=${file##*/} | |
ext=${basename##*.} | |
filename=${basename%.*} | |
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -dQUIET -sOutputFile="$path/$filename-min.pdf" "$file" | |
done |
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
import * as tf from '@tensorflow/tfjs' | |
export const tfMultivariateNormal = (mu, sigma) => { | |
[mu, sigma] = [tf.tensor(mu), tf.tensor(sigma)] | |
const [dim] = mu.shape | |
if (!sigma.shape.every(d => d === dim)) | |
throw new Error(`dimension mismatch in tfMultivariateNormal()`) | |
const Z = ((2 * Math.PI) ** dim * tfDet(sigma).arraySync()) ** -0.5 | |
return x => { | |
x = tf.tensor(x) |
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/bash | |
find $1 -type f -iname "*.pdf" -exec sh -c 'convert -density 100 -flatten "$1"[0] "$1".png' x {} \; |
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
import marked from 'marked' | |
// Import and compile markdown files. Adapted from | |
// https://github.com/xiaofuzi/rollup-plugin-md/blob/master/src/index.js | |
export function markdown(options = {}) { | |
if (options.marked) marked.setOptions(options.marked) | |
return { | |
name: `markdown`, | |
transform(md, id) { |
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
import os | |
import sys | |
_, dirname, prefix = sys.argv | |
os.chdir(dirname) | |
files = sorted(f for f in os.listdir() if not f.endswith(".xmp")) | |
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
<script> | |
// This component uses the Google Maps Places API to turn user text input into a | |
// formatted address and lat/lng coordinates. | |
import { onMount } from 'svelte' | |
import { session } from '$app/stores' | |
export let selectHandler | |
export let placeholder = `` | |
export let required = false | |
export let name = `` |
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 | |
# Shell script to upgrade a Python 2 project to Python 3. | |
# If it's a TensorFlow project consider running afterwards: | |
# tf_upgrade_v2 --intree . --outtree . --reportfile tf2_report.txt | |
# [ -x "$(command -v some_binary)" ] checks whether some_binary is | |
# in path and executable. See https://stackoverflow.com/a/26759734. | |
if [ -x "$(command -v 2to3)" ]; then |
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
import argparse | |
import subprocess | |
from typing import Literal | |
__author__ = "Janosh Riebesell" | |
__date__ = "2022-07-04" | |
description = """ | |
Batch merge bot-created PRs. Uses the GitHub CLI (`brew install gh`) which must be | |
authenticated, i.e. `gh auth status` must exit 0. By default asks for confirmation |
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
const argFact = (compareFn) => (array) => array.map((el, idx) => [el, idx]).reduce(compareFn)[1] | |
const argMax = argFact((min, el) => (el[0] > min[0] ? el : min)) | |
const argMin = argFact((max, el) => (el[0] < max[0] ? el : max)) | |
argMin([42, -5, 3.14, 1e6]) // 1 | |
argMax([42, -5, 3.14, 1e6]) // 3 |
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
# %% | |
from __future__ import annotations | |
import warnings | |
from collections import defaultdict | |
from time import perf_counter | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd |
OlderNewer