Skip to content

Instantly share code, notes, and snippets.

View jswrenn's full-sized avatar
🦀

Jack Wrenn jswrenn

🦀
View GitHub Profile
#!/usr/bin/env bash
# traces a binary for 5s, writing out histograms of the latency of every `Futures::poll` fn
export BINARY_PATH="/home/ubuntu/projects/mini-redis/target/debug/mini-redis-server"
# generate `poll_latency.bpf`
echo "interval:s:5 {
print(@latency);
@jswrenn
jswrenn / monascrape.sh
Last active June 2, 2021 16:35
Monasticon Scraper
:>database-raw.json
seq 0 57 \
| xargs -I{} printf 'https://arts.st-andrews.ac.uk/monasticmatrix/monasticon/browse?page=%s\n' {} \
| while read url ; do
xidel -se '//*[@class="view-content"]//a/@href' "$url"
done \
| xargs -I{} printf 'https://arts.st-andrews.ac.uk%s\n' {} \
| while read url ; do
xidel --ignore-namespaces --output-format json-wrapped -se '
curl -s 'https://api.github.com/repos/rust-itertools/itertools/pulls?state=open' \
| jq -r '.[] | .number' \
| pv -q -L4 \
| xargs -I{} curl -s 'https://api.github.com/repos/rust-itertools/itertools/pulls/{}/files' \
| jq -r '.[] | .filename' \
| sort -u
#!/bin/bash
. `which env_parallel.bash`
env_parallel --session
function enrolled_total() {
jq -rc '"<parent>" + .regdemog_html + "</parent>"' \
| ( xidel - -s --xpath='one-or-more(//p[@class="enroll_demog"]/text())' 2>/dev/null \
|| echo "null" ) \
| cut -d' ' -f3
year sats
1960 42
1961 58
1962 98
1963 95
1964 124
1965 175
1966 170
1967 173
1968 161
macro_rules! pairs{
() => {};
($h : expr, $($t : expr,)*) =>
{
println!("({},{})", $h, $h);
$(println!("({},{})", $h, $t);)*
$(println!("({},{})", $t, $h);)*
pairs!{$($t,)*}
}
}
/// Inspired by https://github.com/nastevens/predicates-rs/
#![feature(conservative_impl_trait)]
use std::ops::*;
#[inline(always)]
fn partial<F, A, B, R>(f : F, b : B)
-> impl Fn(A) -> R
where F: Fn(&A, &B) -> R
@jswrenn
jswrenn / Cargo.toml
Last active November 6, 2016 22:53
Fireplace 2.0
[package]
name = "fireplace"
version = "0.0.1"
authors = ["John Wrenn <johnswrenn@gmail.com>"]
[dependencies]
itertools = "0.5.4"
term_size = "0.2.1"
@jswrenn
jswrenn / retrogit.sh
Last active November 11, 2016 17:04
Commit each file in the current working directory using its time of last modification.
git ls-files -z --others --exclude-standard \
| xargs -0 -I{} stat -c "%Y %n" "{}" \
| sort \
| cut -d' ' -f 2- \
| while read -r name; do
DATE=$(stat -c "%y" "$name")
git add "$name"
export GIT_AUTHOR_DATE="$DATE"
export GIT_COMMITTER_DATE="$DATE"
git commit -m "$name";
@jswrenn
jswrenn / .critical-stats-enrollment.xslt
Last active October 3, 2016 18:01
Bash Client for Critical Review
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/other-reviews">
<xsl:for-each select="review-header">
<xsl:value-of select="@edition"/>
<xsl:text> </xsl:text>
<xsl:value-of select="enrollment"/>
<xsl:text>&#xA;</xsl:text>
</xsl:for-each>