Skip to content

Instantly share code, notes, and snippets.

@nickrw
nickrw / volsay.sh
Created April 19, 2013 12:43
volsay: Wrapper around OSX's `say' command, which sets the system volume to the requested level, then restores volume / mute state once speech is complete.
#!/bin/bash
function usage() {
echo "usage: $0 <volume (0-100)> <say args...>"
echo
echo "Unmutes and sets the system volume to volume%, passing the remaining"
echo "arguments to the OSX \`say' command, restoring volume / mute setting"
echo "to previous values after the speech has completed."
exit 1
}
@nickrw
nickrw / i3lock.sh
Last active March 20, 2019 09:45
i3 screen lock
#!/bin/bash
# depends: scrot imagemagick keychain rivalctl
# Take a screenshot
scrot /tmp/lockshot.png
# Apply pixellation effect
convert /tmp/lockshot.png -scale 5% -scale 2000% /tmp/lockshot-pixel.png
@nickrw
nickrw / homecontrol_curtains.go
Last active January 12, 2018 00:01
A curtains HomeKit Accessory hello world using homecontrol https://github.com/brutella/hc
package main
import (
"fmt"
"log"
"sync"
"time"
"github.com/brutella/hc"
"github.com/brutella/hc/accessory"
#!/bin/bash
# usage: ./remove-mkv-subtitles.sh [--no-dry] [path(s)]
# Script to find MKV files in the given paths and remove subtitle tracks from them. Dry run by default.
# (usually) non-default dependencies: mkvtoolnix, dc
remvsub(){
set -e
@nickrw
nickrw / elb_dns_log.py
Created April 5, 2017 15:42
ELB DNS logger
#!/usr/bin/env python
# Logs all IP addresses for every ELB in an AWS account
import boto3
import dns.resolver
from dns.exception import DNSException
import logging
logger = logging.getLogger('elbdns')
@nickrw
nickrw / postgres_locks.sql
Created March 10, 2017 10:36
A query for showing the locks in a postgres db
SELECT t.relname, l.locktype, page, virtualtransaction, pid, mode, granted
FROM pg_locks l, pg_stat_all_tables t
WHERE l.relation=t.relid
ORDER BY relation ASC;
@nickrw
nickrw / nextcal.sh
Last active September 7, 2016 16:41
nextcal.sh
#!/bin/sh
# Fetches the next item in your google calendar (assuming pre-set-up by running gcalcli)
CALENDAR_NAME=""
cal="$(gcalcli \
--nostarted \
--calendar $CALENDAR_NAME \
--nocolor \
@nickrw
nickrw / spotify-remote.sh
Last active August 26, 2016 15:06
spotify-remote.sh
#!/bin/bash
## My spotify related i3 bindings which use this script
# bindsym XF86AudioPlay exec --no-startup-id ~/bin/spotify-remote.sh playpause
# bindsym XF86AudioStop exec --no-startup-id ~/bin/spotify-remote.sh pause
# bindsym XF86AudioPrev exec --no-startup-id ~/bin/spotify-remote.sh previous
# bindsym XF86AudioNext exec --no-startup-id ~/bin/spotify-remote.sh next
## and other related spotify workspace stuff
# for_window [class="^Spotify"] move to workspace Music
{
"Statement": [
{
"Sid": "PackerSecurityGroupAccess",
"Action": [
"ec2:CreateSecurityGroup",
"ec2:DeleteSecurityGroup",
"ec2:DescribeSecurityGroups",
"ec2:AuthorizeSecurityGroupIngress",
"ec2:RevokeSecurityGroupIngress"
awk '/^[0-9]{2}:[0-9]{2} <@twgbot> (Game|Fun) starting! (.*):/ { sub("^(.*:){2}\\s",""); total += NF; count++ } END {print "Average of " total/count " players per game. " count " games played."}' \#werewolf.log