Skip to content

Instantly share code, notes, and snippets.

Avatar

Max Arnold max-arnold

View GitHub Profile
@max-arnold
max-arnold / ydb-tli-test.py
Created December 4, 2022 11:35
YDB async Python playground script to trigger the TLI scenario
View ydb-tli-test.py
#!/usr/bin/env python
import os
import asyncio
import ydb
JOB_DDL = """
CREATE TABLE job (
id String NOT NULL,
status String,
@max-arnold
max-arnold / yc-agw.py
Last active December 12, 2022 08:34
Test Yandex Cloud Functions written in Python and invoked as API Gateway integrations locally
View yc-agw.py
#!/usr/bin/env python
"""
Test Yandex Cloud Functions written in Python and invoked as API Gateway integrations locally.
Heavily based on https://github.com/amancevice/python-lambda-gateway
MIT License
Copyright (c) 2020 Alexander Mancevice
Copyright (c) 2022 Max Arnold
@max-arnold
max-arnold / salt_zsh_bash_completion.md
Last active January 11, 2022 22:07
SaltStack Zsh and Bash completion
View salt_zsh_bash_completion.md

Zsh

mkdir -p ~/.zsh/completions
wget -q https://raw.githubusercontent.com/saltstack/salt/master/pkg/salt.zsh -O ~/.zsh/completions/_salt
sed -i'' -e 's/python2/python/' ~/.zsh/completions/_salt
# ~/.zshrc
@max-arnold
max-arnold / .bashrc
Created September 22, 2020 07:40
Salt Jinja tester CLI function
View .bashrc
# https://twitter.com/SaltTips/status/1308079610555494403
function sj() {
if [ $# -lt 2 ]; then echo "Usage: sj MINION 'Jinja string'"; return 1; fi
sudo salt "$1" slsutil.renderer default_renderer=jinja string="$2"
}
@max-arnold
max-arnold / rename.sls
Last active March 23, 2020 08:11
Rename a Salt minion
View rename.sls
# Save into salt://rename.sls then run the following command:
# salt-run state.orch rename pillar='{"old": "OLD_NAME", "new": "NEW_NAME"}'
#
# For more tips like this, follow https://twitter.com/SaltTips
{% set old_name = pillar['old'] %}
{% set new_name = pillar['new'] %}
Rename minion id:
salt.function:
@max-arnold
max-arnold / system_boot.py
Created February 9, 2020 14:42
Salt minion system boot beacon
View system_boot.py
# Save into salt://_beacons/system_boot.py and then run
# saltutil.sync_beacons
from __future__ import absolute_import, unicode_literals
__virtualname__ = 'system_boot'
def beacon(config):
"""
beacons:
@max-arnold
max-arnold / export-salt-cloud-issues.py
Last active September 20, 2019 06:54
Export Salt Cloud issues to XLSX
View export-salt-cloud-issues.py
#!/usr/bin/env python3
import argparse
import json
import os
import re
import urllib.parse
import urllib.request
import xlsxwriter
@max-arnold
max-arnold / export-salt-cloud-driver-functions.py
Last active September 20, 2019 06:54
Export Salt Cloud driver functions to XLSX
View export-salt-cloud-driver-functions.py
#!/usr/bin/env python3
import argparse
import ast
import os
import sys
import xlsxwriter
@max-arnold
max-arnold / tt_safari_to_firefox.applescript
Last active June 25, 2019 08:24
Safari to Firefox tab transporter
View tt_safari_to_firefox.applescript
-- Transport tabs from one browser to another. This script moves tabs from Safari to Firefox
-- config
property sourceBrowser : "Safari"
property destinationBrowser : "Firefox"
on run
assertRunning()
assertHasOpenWindow()
set sourceWindow to assertFrontmost()
@max-arnold
max-arnold / safari-reading-list-export.py
Last active June 25, 2019 07:29
Export Safari Reading List to CSV
View safari-reading-list-export.py
#!/usr/bin/env python3
# A script to export (backup) Safari Reading List
import os
import plistlib
with open(os.path.expanduser('~/Library/Safari/Bookmarks.plist'), 'rb') as fp:
plist = plistlib.load(fp)
bookmarks = [
ch['Children'] for ch in plist['Children']