Skip to content

Instantly share code, notes, and snippets.

@aidanhmiles
aidanhmiles / setup
Created October 10, 2021 19:24
Turbo frames with CGI
#!/usr/bin/env bash
mkdir -p webroot/cgi-bin
# place files in their locations as described above
chmod u+x webroot/cgi-bin/*
npm install --save @hotwired/turbo@7.0.1
python3 -m http.server --cgi # or whichever server
@aidanhmiles
aidanhmiles / panel_fileinput_demo.py
Last active November 8, 2020 20:33
This Python script demonstrates how to run analyses on user-submitted data files using Panel. It runs a Holoviz Panel webpage with a single Plotly line chart which is fed by a FileInput that accepts only CSVs.
# python 3.7+
# install dependencies:
# pip install panel pandas plotly
# run it: panel serve --show thisfile.py
import io
import param
import panel as pn
import pandas as pd
import plotly.express as px
@aidanhmiles
aidanhmiles / promise-retry-1.js
Created May 11, 2017 04:45
One way to retry promises
const lodash = require('lodash');
function main () {
// Arbitrary async operation. Sums two coin-flips (random 0 or 1). Only resolves when the sum is 0.
function asyncOperation() {
return new Promise((resolve, reject) => {
let sum = lodash(new Array(2))
.fill(null)
.map(() => Math.round(Math.random()))
@aidanhmiles
aidanhmiles / move_files.sh
Created January 31, 2017 21:51
Copy files from A to B, preserving directory hierarchy from wherever the script is executed
#!/usr/bin/env bash
main() {
local files=()
# Method 1
# while read -r fname; do
# derp+=("$fname")
# done < <(ag -g html base/)

Keybase proof

I hereby claim:

  • I am aidanhmiles on github.
  • I am aidanhmiles (https://keybase.io/aidanhmiles) on keybase.
  • I have a public key ASCIzh8EBfOMVfl1XSEFphNxSNO2jvfLg1NdvAhlvokWqQo

To claim this, I am signing this object: