Skip to content

Instantly share code, notes, and snippets.

45.380328, -63.266579
@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)
@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 / bitbucket-archive.py
Last active March 4, 2020 06:04
With atlassian falling apart and abandoning mercurial (the only reason to use bitbucket unless you're one of those anti-microsoft holdouts) you may find yourself looking to collect all your bitbucket repos to take elsewhere ... like ... github. This script is the first step. This is the first draft, only tested on mac running python 3.7 but shou…
from requests import get
from os import environ, getcwd, chdir, mkdir, system
from json import dumps
basedir = getcwd() + '/repos'
mkdir(basedir)
username=environ['BITBUCKET_USER']
password=environ['BITBUCKET_PASS']
team=environ['BITBUCKET_TEAM']
@xcsrz
xcsrz / abort-trap-6-fix.sh
Created March 11, 2020 00:14
fix for when `macos catalina upgrade` makes random scripts bomb with `Abort trap: 6`
brew update && brew upgrade && brew install openssl
cd /usr/local/Cellar/openssl/1.0.2*/lib
sudo cp libssl.1.0.0.dylib libcrypto.1.0.0.dylib /usr/local/lib/
cd /usr/local/lib
sudo ln -s libssl.1.0.0.dylib libssl.dylib
sudo ln -s libcrypto.1.0.0.dylib libcrypto.dylib
@xcsrz
xcsrz / pemify-your-private-ssh-key.sh
Created April 5, 2020 19:31
This one command is so hard to track down every 3 years when I need it. So many posts incorrectly insist the private key is in PEM format already. In truth, it depends on how the key pair was created (openssl vs ssh-keygen).
# NOTE: this updates the file in place, do you have a backup?
ssh-keygen -p -m PEM -f ~/.ssh/id_rsa
@xcsrz
xcsrz / certificate-dates.sh
Created April 16, 2020 03:03
Print the dates from an SSL certificate
openssl x509 -noout -dates -in cert.pem
@xcsrz
xcsrz / material-ui-starter-pre-react-hooks.sh
Created May 8, 2020 15:19
When you need to jump start a material-ui project with the pre-hooks version of react. (react v16.7, material-ui v3.7.1)
curl https://codeload.github.com/mui-org/material-ui/tar.gz/v3.7.1 | tar -xz --strip=2 material-ui-3.7.1/examples/create-react-app
@xcsrz
xcsrz / es-backup-control.py
Created October 10, 2020 19:15
This python script is used to increase the number of replicas in an ES cluster and force those new replicas to be allocated to a new host to enable a filesystem backup of the ES data directory.
from requests import get, post, put
from json import dumps, loads
from sys import argv
from math import ceil
commands = []
def addShard(idx, shard):
commands.append({
"allocate" : {
@xcsrz
xcsrz / mira-milk-frother-instructions.md
Created December 9, 2020 20:39
Mira Milk Frother Usage
  • To warm and froth milk:
Push the on button once
- blue indicator lights up
  • To only warm milk:
Push the on button two time
- blue indicator lights up (not helpful)