This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # step-ssh.sh - SSH wrapper with automatic Smallstep certificate authentication | |
| # | |
| # Usage: step-ssh [ssh-options] user@host [command] | |
| # | |
| # For 192.168.1.* hosts, automatically checks for valid certificate | |
| # and obtains one via Google OAuth if needed. | |
| # | |
| # Add to ~/.bashrc or ~/.zshrc: | |
| # alias ssh='/home/{USER}/.local/bin/step-ssh.sh' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| from pathlib import Path | |
| from django.core import management | |
| from django.core.management.base import BaseCommand | |
| import boto3 | |
| from botocore.config import Config | |
| from botocore.exceptions import ClientError |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "raw_command": "from django.db import connection;c = connection.cursor();table = 'TABLENAME';sql = f'TRUNCATE TABLE {table} CASCADE';c.execute(sql)" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class ArrayFieldCheckboxSelectMultiple(CheckboxSelectMultiple): | |
| """A CheckboxSelectMultiple widget for use with ArrayField which fixes the Multiple items not selected issue""" | |
| def format_value(self, value): | |
| """Return selected values as a list.""" | |
| if value is None and self.allow_multiple_selected: | |
| return [] | |
| elif self.allow_multiple_selected: | |
| value = [v for v in value.split(",")] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def create_drop_tables_raw_command(tables: list[str]) -> str: | |
| """Get list of tables using the 'manage sqlflush' command. This will create the DROP TABLE command for resetting the database""" | |
| django_migrations_table = "django_migrations" | |
| if django_migrations_table not in tables: | |
| print(f"-- '{django_migrations_table}' not given, adding to tables!") | |
| tables.append(django_migrations_table) | |
| statements = ["from django.db import connection"] | |
| statements.append("cursor = connection.cursor()") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Get/Set lambda environment variables | |
| """ | |
| import os | |
| import pprint | |
| from pathlib import Path | |
| from typing import Tuple, List | |
| from enum import Enum | |
| import boto3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from time import sleep | |
| from subprocess import check_output, CalledProcessError | |
| controller_identifier = 'microKEY2' | |
| configured = False | |
| while True: | |
| aconnect_list_command = ('aconnect', '-o') | |
| output_bytes = check_output(aconnect_list_command) | |
| output_str = output_bytes.decode('utf8') | |
| controller_attached = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh | |
| # rasbian | |
| # add the following line to /etc/rc.local above the "exit 0" line to start on boot | |
| # /home/pi/autostartsynth.sh & | |
| killall fluidsynth | |
| # set sound | |
| export DESIRED_SOUNDFONT=/usr/share/sounds/sf2/FluidR3_GM.sf2 | |
| # start fluidsynth with desired sound |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import boto3 | |
| S3_CLIENT = boto3.client("s3") | |
| def iterate_s3_csv(bucket: str, key: str) -> Generator: | |
| with BytesIO() as bytesin: | |
| S3_CLIENT.download_fileobj(bucket, key, bytesin) | |
| bytesin.seek(0) | |
| stringin = StringIO(bytesin.read().decode("utf8")) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """ | |
| Get/Set lambda environment variables | |
| """ | |
| import os | |
| import pprint | |
| from pathlib import Path | |
| from typing import Tuple, List | |
| from enum import Enum | |
| import boto3 |
NewerOlder