Skip to content

Instantly share code, notes, and snippets.

View keeth's full-sized avatar

Keith Grennan keeth

View GitHub Profile
@keeth
keeth / dataview-task-stats.js
Last active June 18, 2025 23:26
Obsidian DataviewJS snippet to show task completion counts by day, week and month
const now = window.moment();
// === Helper: Group tasks by a time unit ===
function groupTasksByTimeframe(tasks, unit, format) {
return Array.from(tasks).reduce((acc, task) => {
const key = window.moment(task.completion.toJSDate()).startOf(unit).format(format);
console.log(key);
acc[key] = (acc[key] || 0) + 1;
return acc;
}, {});
@keeth
keeth / keiths-obsidian-custom-statuses.css
Last active June 9, 2025 21:44
Obsidian Tasks Custom Status Icons CSS Snippet
/* [w] waiting */
input[data-task="w"],
li[data-task="w"] > input,
li[data-task="w"] > p > input {
&:checked {
color:var(--color-orange);
-webkit-mask-image: url("data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2020%2020%22%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%2210%22%20r%3D%228%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22%20fill%3D%22none%22/%3E%3Cline%20x1%3D%2210%22%20y1%3D%2210%22%20x2%3D%2210%22%20y2%3D%225%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22/%3E%3Cline%20x1%3D%2210%22%20y1%3D%2210%22%20x2%3D%2213%22%20y2%3D%2210%22%20stroke%3D%22currentColor%22%20stroke-width%3D%222%22/%3E%3C/svg%3E");
}
}
@keeth
keeth / Dockerfile
Created April 5, 2023 16:48
Multi-arch BigTable emulator docker image
FROM python:3-slim
COPY build.sh /build.sh
RUN apt-get update -qqy && apt-get install -qqy curl netcat &&\
curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud-cli-424.0.0-linux-arm.tar.gz -o google-cloud-cli.tar.gz &&\
tar -xf google-cloud-cli.tar.gz &&\
rm google-cloud-cli.tar.gz &&\
/google-cloud-sdk/install.sh --quiet --usage-reporting=false --screen-reader=false --command-completion=false --path-update=false &&\
/build.sh &&\
apt-get clean
#!/bin/bash
apt update
apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
apt update
apt install -y docker-ce
usermod -aG docker ubuntu
@keeth
keeth / whitewater.ts
Created December 30, 2022 15:26
Scrape weather conditions from whitewater website
import { JSDOM } from 'jsdom';
import fetch from "node-fetch";
export type WhitewaterConditions = {
weather: string;
overnightSnowCm: number;
baseTempDegC: number;
}
const WEB_URL = 'https://skiwhitewater.com/conditions/';
@keeth
keeth / index.js
Last active November 4, 2022 19:04
CSP report rate-limiting proxy (cloud function)
const { createClient } = require("redis");
const fetch = require("node-fetch");
const REQUESTS_LIMIT = 1;
const TTL = 60; // seconds
const client = createClient({
url: process.env.REDIS_URL,
});
@keeth
keeth / new-mac-setup.sh
Last active May 16, 2024 21:20
New Mac Setup Commands
#!/bin/bash
# homebew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
# essential cli
brew install\
bash\
python\
go\
@keeth
keeth / isNetworkError.js
Last active February 20, 2020 20:30
Is it a fetch network error? (for the purpose of retrying on failure).
/*
https://twitter.com/xinganwang/status/1189266788237885443
github/fetch: TypeError: Network request failed
Chrome: TypeError: Failed to fetch
Firefox: TypeError: NetworkError when attempting to fetch resource.
Safari: TypeError: The Internet connection appears to be offline.
*/
const isNetworkError = e =>
@keeth
keeth / pingmon.py
Created October 10, 2019 21:52
Monitor packet loss to a particular host and send statistics to Cloudwatch
import threading
import time
import logging
logging.basicConfig(level=logging.INFO, format='[%(levelname)s %(asctime)s %(name)s] %(message)s')
logger = logging.getLogger('pingmon')
logger.setLevel(logging.INFO)
import boto3

Keybase proof

I hereby claim:

  • I am keeth on github.
  • I am keeth (https://keybase.io/keeth) on keybase.
  • I have a public key ASCgC0494QvYPRo5H-dPDtqY-Z6mIsW_Z8Hk9PhsfnWhQAo

To claim this, I am signing this object: