Skip to content

Instantly share code, notes, and snippets.

@tyzbit
tyzbit / zoom-mute-status.scpt
Created September 14, 2019 17:11
Get Zoom Mute/Unmute Status
property btnTitle : "Mute audio"
tell application "System Events" to tell application process "zoom.us"
if exists (menu item btnTitle of menu 1 of menu bar item "Meeting" of menu bar 1) then
do shell script "echo Unmuted"
else
do shell script "echo Muted"
end if
end tell
@conorsch
conorsch / circle-ci-checkout-special-step
Created August 16, 2017 21:27
Full script of the special "checkout" step in CircleCI
#!/bin/sh
set -e
# Workaround old docker images with incorrect $HOME
# check https://github.com/docker/docker/issues/2968 for details
if [ "${HOME}" = "/" ]
then
export HOME=$(getent passwd $(id -un) | cut -d: -f6)
fi
@fhatz
fhatz / MultiRoom.sh
Last active January 23, 2025 19:18
Samsung Multiroom - Console client
#! /bin/bash
# Author: F. Hatz
# based on 'https://github.com/bacl/WAM_API_DOC'
# start with MultiRoom.sh search (search for speakers)
# or with MultiRoom.sh Speaker-IP UUID OBJECTID [OBJECTID OBJECTID ...] volume
# or with MultiRoom.sh Speaker-IP fav1/fav2/fav3/radio1/radio2/radio3 volume
# or with MultiRoom.sh Speaker-IP play/pause/stop (song: play/pause radio: stop)
# or with MultiRoom.sh Speaker-IP next/previous
# or with MultiRoom.sh Speaker-IP mute on/off

Scaling your API with rate limiters

The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.

In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.

Request rate limiter

This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.

@itod
itod / split_keyboards.md
Last active April 9, 2026 03:46
Every "split" mechanical keyboard currently being sold that I know of
local name = KEYS[1];
local rate = tonumber(KEYS[2]);
local max = tonumber(KEYS[3]);
local interval = tonumber(KEYS[4]);
local now = tonumber(KEYS[5]);
local count = tonumber(redis.call('HGET', name, 'count'));
local mtime = tonumber(redis.call('HGET', name, 'mtime'));
if not mtime then
count = max;
mtime = now;
#!/bin/bash
#
# This script will mount /Users in the boot2docker VM using NFS (instead of the
# default vboxsf). It's probably not a good idea to run it while there are
# Docker containers running in boot2docker.
#
# Usage: sudo ./boot2docker-use-nfs.sh
#
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@igrigorik
igrigorik / github.bash
Last active September 12, 2025 09:24
Open GitHub URL for current directory/repo...
alias gh="open \`git remote -v | grep git@github.com | grep fetch | head -1 | cut -f2 | cut -d' ' -f1 | sed -e's/:/\//' -e 's/git@/http:\/\//'\`"