Skip to content

Instantly share code, notes, and snippets.

stuart-warren /
Last active Mar 2, 2021
Google Workspace countdown timer add-on
function onOpen(e) {
.addItem('Start', 'showSidebar')
function onInstall(e) {
stuart-warren / .bashrc
Last active Dec 28, 2021
search google from terminal
View .bashrc
# get back a list of urls for search term
# $ goog stuart-warren github
# $ goog ValueError
goog() {
# uses
if [[ "$1" == "-v" ]]; then v="-v"; fi
curl ${v} -LG --data-urlencode "q=${query}" \
--data-urlencode "sourceid=chrome" \
stuart-warren / greengrass-ota.service
Created Sep 14, 2020
Example AWS IOT Greengrass Systemd unit files
View greengrass-ota.service
Description=Greengrass OTA Daemon
stuart-warren /
Last active Jul 23, 2020
Ensure you have quota to create Elastic IPs in CI to avoid failing test randomly
import boto
import time
ec2 = boto3.Session(region_name="eu-west-1").client('ec2')
eips_to_create = 9
def get_eip_quota():
# get limit of ElasticIps for account
quota = 0
for acc_attr in ec2.describe_account_attributes().get('AccountAttributes'):
stuart-warren / docker-compose.yml
Last active Dec 28, 2021
Start chrome with docker-compose (helps with aws greengrass iot core also)
View docker-compose.yml
version: "3.8"
network_mode: "host"
image: jess/chrome
DISPLAY: 'unix:0'
- /run/dbus/system_bus_socket:/run/dbus/system_bus_socket
View tmux.conf
# Tmux should be pretty, we need 256 color for that
set -g default-terminal "screen-256color"
# Tmux uses a 'control key', let's set it to 'Ctrl-a'
# Reason: 'Ctrl-a' is easier to reach than 'Ctrl-b'
set -g prefix C-a
unbind C-b
# mouse options
set -g mouse on
# move around buffer like vi
stuart-warren /
Last active Sep 2, 2021 — forked from nitaku/
Freehand drawing

A simple freehand drawing application, based on Bostock's Line Drawing gist.

Use your stylus, fingers or mouse to draw. The color of the line can be changed by interacting with the color palette, and the canvas can be cleared by clicking the trash in the upper-right corner of the UI.

The application uses two stacked SVG elements, one for the UI and one for the canvas. This is used to disable drawing when interacting with UI elements.

Unlike Bostock's example, this application maintains a DOM-independent object to store all the drawing's data (just look at the JavaScript console each time you complete a line).

stuart-warren /
Last active Dec 27, 2019
chrome history fetcher
# requires sqlite3 with json1 compiled in
# `brew edit sqlite3` add '--with-json1' to install args
# `brew reinstall sqlite3 -s`
cp -f "$HOME/Library/Application Support/Google/Chrome/Default/History" "$h"
sqlite3 "$h" "SELECT json_object('url', url, 'title', title) from urls where last_visit_time/1000000-11644473600 between strftime('%s','now')-86400 and strftime('%s','now') order by last_visit_time desc;" | jq -s '.' | less
rm -f "$h"
stuart-warren / kubectx.zsh
Last active Feb 4, 2022
kubectx/kubens multi context magic
View kubectx.zsh
# BSD 2-Clause License
# Copyright (c) 2019, Stuart Warren
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.