Skip to content

Instantly share code, notes, and snippets.

@xcsrz
xcsrz / armagetron-build-instructions.md
Created January 11, 2022 17:04
Building Armagetron on macos (worked on Catalina)

Install Dependencies

brew install pkg-config autoconf automake sdl2 sdl2_image sdl2_mixer protobuf-c glew boost ftgl dylibbundler create-dmg

Setup

./bootstrap.sh
@xcsrz
xcsrz / getContentHash.py
Last active December 20, 2021 20:19
Python port of the getContentHash() function from PHP's Composer. Useful when updating composer.lock from php when composer is available. Granted this "shouldn't be done" and is "doing it wrong", but sometimes running composer commands in your deployment chain is overkill and redundent.
import hashlib
from json import dumps
from collections import OrderedDict
# composerFileContents should be the dict version of the composer.json file
def getContentHash(composerFileContents):
relevant = OrderedDict((key, composerFileContents[key]) for key in composerFileContents.keys() if key in ['name','version','require','require-dev','conflict','replace','provide','minimum-stability','prefer-stable','repositories','extra'])
if 'config' in composerFileContents and 'platform' in composerFileContents['config']:
relevant['config']['platform'] = composerFileContents['config']['platform']
@xcsrz
xcsrz / flush-elasticsearch.sh
Created November 13, 2021 22:13
Sometimes you just need to delete everything in an elasticsearch cluster and you don't have access to do the stop-rm-rf-start thing.
for idx in $(curl -sS https://${DOMAIN}:${PORT}/_cat/indices | awk '{print $3}'); do curl -XDELETE "https://${DOMAIN}:${PORT}/${idx}"; done
@xcsrz
xcsrz / accessing child accounts in aws.md
Created October 11, 2021 17:42
Accessing "member accounts" of your AWS organization. Since the AWS documentation and all the write-ups are more complicated than useful, there's the cliff notes.
@xcsrz
xcsrz / webtask-backup.py
Created May 10, 2021 21:05
Backup your webtask code. Can be used to make sure you have the latest version of your code locally, or used to backup in case at some point webtask.io ceases to function. Considering they very recently started failing to install new npm modules, this could be any point now I fear.
import subprocess
from json import dumps
# NOTE: Files will be written to the current directory, without any checks to prevent overwriting. Archiving and/or version control are not considered here, but highly encouraged.
# get a list of all webtasks for the current user
list_request = subprocess.run(['wt', 'ls'], stdout=subprocess.PIPE, text=True)
# transform that output into a list of task names
tasks = [ ln.replace('Name:','').strip() for ln in list_request.stdout.split("\n") if 'Name:' in ln ]
@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)
@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 / 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 / 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 / certificate-dates.sh
Created April 16, 2020 03:03
Print the dates from an SSL certificate
openssl x509 -noout -dates -in cert.pem