Skip to content

Instantly share code, notes, and snippets.

@silviot
silviot / vast.ai.sd.setup.sh
Last active July 25, 2024 13:34
Setup stable diffusion UI on a vast.ai machine
#!/bin/bash
# Use this script to set up a stable diffusion web GUI on a vast.ai machine. Invoke it like this:
# run:
#
# wget -q -O - https://gist.githubusercontent.com/silviot/bdf1d0d68901419935463e8d74bc0cd6/raw/vast.ai.sd.setup.sh | bash
AUTOMATIC1111_VERSION=${AUTOMATIC1111_VERSION:-master}
@silviot
silviot / install_micro_and_set_it_as_default_editor.sh
Created May 10, 2022 13:26
Install micro and set it as default editor
#!/bin/sh
set -e
wget -O- https://getmic.ro | sh
sudo mv micro /usr/local/bin/
echo 'export EDITOR="micro"' >> ~/.bashrc
echo 'export VISUAL="$EDITOR"' >> ~/.bashrc
@silviot
silviot / Removing_grok.rst
Last active January 30, 2023 22:58
Removing grok

Removing grok

Grok is no longer supported in Plone 5.2 (the first Plone to run on Python 3). Every grok statement can be easily expressed with ZCML. This guide shows how to change code to register ZCA components using ZCML instead of grok.

Form from plone.directives.form

@silviot
silviot / fix-jsdom.sh
Created January 8, 2021 15:15
Apply patch to jsdom
#!/bin/bash
# This PR lays unmerged, so we apply it with this script:
# https://github.com/jsdom/jsdom/pull/3073
find node_modules/ -name xhr-utils.js -exec patch -N -r- {} ./jsdom.patch \;
#!/bin/sh
# Script to migrate a zodb from python 2 to python 3
# Needs to be run inside a buildout directory
# It is meant to automate the procedure documented here:
# https://docs.plone.org/manage/upgrading/version_specific_migration/upgrade_zodb_to_python3.html
BUILDOUT_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
@silviot
silviot / sanity.py
Last active March 5, 2020 12:14
Restore sanity to degraded pdb
import logging
import sys
import termios
fd = sys.stdin.fileno()
(iflag, oflag, cflag, lflag, ispeed, ospeed, cc) = termios.tcgetattr(fd)
lflag |= termios.ECHO
new_attr = [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]
termios.tcsetattr(fd, termios.TCSANOW, new_attr)
#!/usr/bin/env python
"""Monitor signal strength of wifi deauthentication packets
"""
from ascii_graph import Pyasciigraph
from ascii_graph.colordata import hcolor
from ascii_graph.colordata import vcolor
from ascii_graph.colors import Blu, Red, Yel, Gre
from scapy.all import Dot11, sniff
from datetime import datetime
from itertools import groupby
@silviot
silviot / reboot.yml
Last active May 9, 2018 07:46
Reboot server and wait for restart with ansible
# After way too many attempts, this one seems to really work all the time
- name: Reboot server
shell: sleep 2 && reboot
async: 1
poll: 0
failed_when: false
become: true
- name: Wait for server to initiate shutdown
#!/usr/bin/env python
from dns import resolver # dnspython
from dns import reversename
from dns import rdatatype
from ntplib import NTPClient # ntplib
from ntplib import NTPException
NTP_NAME = '0.europe.pool.ntp.org'
NTP_NAME = '0.us.pool.ntp.org'
@silviot
silviot / es_status.sh
Last active February 16, 2016 12:38
Elasticsearch zabbix External check script
#!/bin/bash
HOST=$1
METRIC=$2
if [ "x$HOST" = "x" ] || [ "x$METRIC" = "x" ]; then
exit 1
fi
curl "http://$HOST:9200/_cluster/health?format=yaml&pretty=1" 2> /dev/null | grep $METRIC | cut -f2 -d ' ' | sed -e 's/"//g'