Skip to content

Instantly share code, notes, and snippets.

#include <Wire.h>
#include <ACAN2040.h>
#include <Adafruit_NeoPixel.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// NeoPixel strip, for showing shift lights.
//
#define NEOPIXEL_PIN 15
@oesmith
oesmith / screenshot-window.sh
Created February 9, 2024 14:22
Take a screenshot of the current focused window in Sway
#!/bin/bash
swaymsg -t get_tree \
| jq -j '.. | select(.type?) | select(.focused).rect | "\(.x),\(.y) \(.width)x\(.height)"' \
| grim -g - - \
| wl-copy \
&& notify-send -t 3000 "Screenshot" "Window captured"
@oesmith
oesmith / powermenu.sh
Created February 9, 2024 14:21
Power menu (power off / reboot / suspend / etc) for Wayland desktops using Wofi
#!/usr/bin/env bash
op=$( echo -e " Poweroff\n Reboot\n Suspend\n Lock\n Logout" | wofi -i --dmenu --width 300 --height 200 | awk '{print tolower($2)}' )
case $op in
poweroff)
;&
reboot)
;&
suspend)
@oesmith
oesmith / get-bing-wallpaper.sh
Created October 19, 2021 09:11
Automatically downloads today's wallpaper from Bing (bash + curl + jq)
#!/bin/bash
set -ex
api_url="https://www.bing.com/HPImageArchive.aspx?format=js&idx=0&n=1&mkt=en-US"
base_url="https://www.bing.com"
output=$HOME/wallpapers/bing-wallpaper.jpg
# Fetch the URL from the Bing API endpoint.
import datetime
# Monthly house price index, starting in January 1991. Extracted from the
# Nationwide monthly house price index. Licensing and more info available at:
# http://www.nationwide.co.uk/about/house-price-index/headlines
RAW_INDEX = [
105.83, 106.72, 105.52, 107.08, 108.49, 109.93, 108.80, 107.81, 106.25,
106.66, 105.77, 105.94, 103.64, 103.44, 103.69, 103.69, 105.16, 105.54,
105.18, 104.36, 101.93, 101.14, 98.95, 99.24, 99.90, 100.49, 100.12,
103.09, 101.54, 105.30, 104.22, 103.13, 102.09, 102.16, 100.97, 102.58,
@oesmith
oesmith / screenrc
Created September 27, 2011 06:50
My screenrc
hardstatus on
hardstatus alwayslastline
hardstatus string '%{= kG} %{W}%H %{g}[%= %{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}] %{W}%d-%m-%Y %c %{g}'
#terminfo and termcap for nice 256 color terminal
# allow bold colors - necessary for some reason
#attrcolor b ".I"
# tell screen how to set colors. AB = background, AF=foreground
#termcapinfo xterm "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm"
#termcapinfo xterm-color "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm"
# erase background with current bg color
@oesmith
oesmith / janus.rake
Created September 27, 2011 06:49
My janus.rake
vim_plugin_task "mru", "git://github.com/ornicar/vim-mru.git"
vim_plugin_task "pyflakes", "git://github.com/kevinw/pyflakes-vim.git"
vim_plugin_task "pydoc", "git://github.com/fs111/pydoc.vim.git"
@oesmith
oesmith / index.html
Created August 13, 2011 21:01
Search howmanyleft
<!doctype html>
<article>
<h1>Super awesome HTML5 page for the searching of howmanyleft.co.uk</h1>
<form action="http://howmanyleft.co.uk/" method="GET">
<input type="search" name="q">
<input type="submit" value="search">
</form>
</article>
@oesmith
oesmith / puppet-install.sh
Created June 28, 2011 12:05
Install Puppet 2.6.2 from lenny-backports on Ubuntu 10.04 LTS
cat > /etc/apt/preferences.d/backports <<EOF
Package: puppet puppet-common puppetmaster facter
Pin: release a=lenny-backports
Pin-Priority: 900
EOF
cat > /etc/apt/sources.list.d/backports.list <<EOF
deb http://backports.debian.org/debian-backports lenny-backports main contrib non-free
EOF
#!/usr/bin/which ruby
#
# Script for adding tickets from Lighthouse to Things.
#
# Requires lighthouse-api and rb-appscript gems
#
# TODO: tags, priorities, more..?
#
# Copyright (c) 2010 Olly Smith
#