Skip to content

Instantly share code, notes, and snippets.

@stuart-warren
stuart-warren / Code.gs
Last active Mar 2, 2021
Google Workspace countdown timer add-on
View Code.gs
function onOpen(e) {
DocumentApp.getUi().createAddonMenu()
.addItem('Start', 'showSidebar')
.addToUi();
showSidebar()
}
function onInstall(e) {
onOpen(e);
}
View tmux-keylogger-notes.md
@stuart-warren
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 site:stackoverflow.com ValueError
goog() {
# uses https://github.com/mgdm/htmlq
query=${@}
v=""
if [[ "$1" == "-v" ]]; then v="-v"; fi
curl ${v} -LG --data-urlencode "q=${query}" \
--data-urlencode "sourceid=chrome" \
@stuart-warren
stuart-warren / greengrass-ota.service
Created Sep 14, 2020
Example AWS IOT Greengrass Systemd unit files
View greengrass-ota.service
[Unit]
Description=Greengrass OTA Daemon
[Service]
Environment=GG_BASE_DIR=/greengrass
Type=forking
Restart=on-failure
RestartSec=5
ExecStart=${GG_BASE_DIR}/ota/ota_agent/ggc-ota
[Install]
WantedBy=multi-user.target
@stuart-warren
stuart-warren / eip.py
Last active Jul 23, 2020
Ensure you have quota to create Elastic IPs in CI to avoid failing test randomly
View eip.py
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
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"
services:
chrome:
network_mode: "host"
image: jess/chrome
environment:
DISPLAY: 'unix:0'
volumes:
- /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
stuart-warren / README.md
Last active Sep 2, 2021 — forked from nitaku/README.md
Freehand drawing
View README.md

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

https://bl.ocks.org/stuart-warren/raw/5d778299fcbcb9b1343aac9d77d0fc49/?raw=true

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
stuart-warren / last-24h-chrome.sh
Last active Dec 27, 2019
chrome history fetcher
View last-24h-chrome.sh
#!/bin/sh
# requires sqlite3 with json1 compiled in
# `brew edit sqlite3` add '--with-json1' to install args
# `brew reinstall sqlite3 -s`
h=$(mktemp)
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
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.