Written by Alex Ganose @utf and Janosh Riebesell @janosh. Published 2022-03-28. Last updated 2024-03-30.
-
Install Xcode command line tools:
xcode-select --install
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 |
<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 = `` |
import os | |
import sys | |
_, dirname, prefix = sys.argv | |
os.chdir(dirname) | |
files = sorted(f for f in os.listdir() if not f.endswith(".xmp")) | |
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) { |
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 |
#!/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 |
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) |
#!/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 |
#!/bin/bash | |
find $1 -type f -iname "*.pdf" -exec sh -c 'convert -density 100 -flatten "$1"[0] "$1".png' x {} \; |