Skip to content

Instantly share code, notes, and snippets.

@xcsrz
xcsrz / adb-fix-kodi-back-button-amazon-fire-tv.md
Last active May 23, 2020 18:09
Does it irritate anyone else as much as me when you hit the back button and the video keep on playing but all you can see is the audio and it's not clear how to make the audio stop? This fixes that on FireTV+Kodi.

Run Directly

curl https://gist.githubusercontent.com/xcsrz/780017ebbd64b2435dc58b1053bf4858/raw/f9d36a87daba4e464a1e61d35172c313ee2fea7f/adb-fix-kodi-back-button-amazon-fire-tv.sh | bash
@xcsrz
xcsrz / wait-until-published.py
Created April 24, 2019 03:06
Python function to wait for a recently published version of an npm package to become available. Too many times I've been bitten by npm publish returning but the package not becoming available for several seconds, minutes and sometimes even hours later. If you automate your deployment with python this can help you too.
import sys
import json
import time
# pip install npm
from npm.bindings import npm_run
def wait(package, version):
while True:
err, raw = npm_run('view','--json', package)
45.380328, -63.266579
@xcsrz
xcsrz / clean-browser-session.sh
Created March 28, 2019 18:54
Run chrome completely separate from the standard as though it has never been run before on that computer, but skip the welcome wizard stuff.
#!/bin/bash
app="/Applications/Google Chrome.app"
dir=$(mktemp -d)
# echo $dir
touch "${dir}/First Run"
mkdir "${dir}/Default"
echo '{"browser":{"has_seen_welcome_page":true}}' > "${dir}/Default/Preferences"
exec "${app}/Contents/MacOS/Google Chrome" --bwsi --disable-signin-promo --bypass-app-banner-engagement-checks --no-managed-user-acknowledgment-check -no-first-run --user-data-dir=${dir} --system-developer-mode
@xcsrz
xcsrz / sendgrid_keys.rb
Created December 7, 2018 22:47
Sendgrid's UI does not give you full control over API keys. This script does. Set two environment variables and you can view your keys, their scopes and add/remove scopes from any key. Simple utility but saves a lot of time and headache.
#!/usr/bin/env ruby
require 'base64'
require 'rest-client'
require 'json'
# https://stackoverflow.com/questions/38613941/sendgrid-error-access-forbidden-when-trying-to-get-user-profile-api
$base_endpiont = "https://api.sendgrid.com/v3/api_keys"
def usage
@xcsrz
xcsrz / bump-to-even-numbers.sh
Last active December 16, 2018 05:36
Bash function to bump minor semantic version number by even numbers.
releaseBumpValue() {
semver="${1}"
local tifs=${IFS}
local IFS='.'
read -ra bits <<< "${semver}"
if [ $((bits[1]%2)) -eq 0 ]; then
echo 2
else
echo 1
fi
@xcsrz
xcsrz / memcached-status.sh
Last active December 16, 2018 05:36
Grab stats from memcached
echo stats | nc 127.0.0.1 11211
@xcsrz
xcsrz / emot.sh
Last active February 8, 2018 22:33
Terminal "utility" to copy ASCII emoji to the clipboard on OSX
#!/bin/bash
EMOTS=(
"¯\_(ツ)_/¯"
"༼ ༎ຶ ෴ ༎ຶ༽"
"「(°ヘ°)"
"(╯°□°)╯︵ ┻━┻"
"༼ つ ◕_◕ ༽つ"
"(✿◠‿◠)"
"¯(°_o)/¯"
@xcsrz
xcsrz / center_text_on_image.py
Created March 8, 2017 00:17
Center text on an image with Python and OpenCV. Had to come up with it myself as no one was spelling this out anywhere (or google couldn't find it)
#!/usr/bin/env python
import numpy as np
import cv2
from time import sleep
# create blank image - y, x
img = np.zeros((600, 1000, 3), np.uint8)
# setup text
@xcsrz
xcsrz / WriteChanCloser.go
Created January 5, 2017 17:42
Modeled after Golang's ioutil package's NopCloser method which wraps an io.Reader interface in an io.ReadCloser facade interface, this code takes an io.Writer and a nil channel and returns an io.WriteCloser interface. The example.go file demonstrates usage in an http.HandleFunc as a very over complicated counter using the worker-and-channel-over…
package main
import "io"
type writeChanCloser struct {
io.Writer
closeChan chan struct{}
}
func (wcc writeChanCloser) Close() error {