Skip to content

Instantly share code, notes, and snippets.

"""
1. Install the following dependencies into a virtualenv
pip install textual==0.57.0 textual-dev==1.5.1 requests==2.31.0 requests-aws4auth==1.2.3 yandexcloud==0.267.0
2. Create a env.json file
{
"YC_REGION": "ru-central1",
"YC_FOLDER_ID": "FFF",
@max-arnold
max-arnold / SALT-EXTENSION.md
Created March 27, 2024 05:07
Salt extension development environment

Here is how I set up my extension development environment on Ubuntu 22.04:

git config --global user.name "Name"
git config --global user.email "[email protected]"
git clone [email protected]:USER/saltext-my.git
cd saltext-my
sudo apt install python3-venv python3-dev build-essential python3-wheel python3-wheel-whl
python3 -m venv .venv
source .venv/bin/activate
@max-arnold
max-arnold / listen.py
Created February 25, 2024 02:35
Continuous voice recognition in Emacs using Yandex Speechkit
# Based on https://cloud.yandex.ru/ru/docs/speechkit/stt/api/microphone-streaming
import pyaudio
import wave
import argparse
import grpc
from datetime import datetime
import time
import queue
import sys
@max-arnold
max-arnold / salt-ssh-vs-heist.md
Last active January 31, 2024 15:04
Salt SSH vs Heist

Feature parity between Salt SSH and Heist

Salt SSH features

@max-arnold
max-arnold / modinfo.py
Created November 14, 2023 02:24
Salt module info
#!/usr/bin/env python3
import argparse
import ast
import os
import sys
def parse_module(mod):
with open(mod, "r") as source:
@max-arnold
max-arnold / ydb-tli-test.py
Created December 4, 2022 11:35
YDB async Python playground script to trigger the TLI scenario
#!/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 March 18, 2024 09:28
Test Yandex Cloud Functions written in Python and invoked as API Gateway integrations locally
#!/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-2023 Max Arnold
@max-arnold
max-arnold / salt_zsh_bash_completion.md
Last active January 11, 2022 22:07
SaltStack Zsh and Bash completion

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
# 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
# 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: