Skip to content

Instantly share code, notes, and snippets.

View pettazz's full-sized avatar
🤷‍♂️
lol

Nick Pettazzoni pettazz

🤷‍♂️
lol
View GitHub Profile
@pettazz
pettazz / transmission-cleanup.py
Last active April 5, 2019 15:45
Delete and remove files for any seeding torrents that have been idle for some number of days
import datetime
import transmissionrpc
from config import TRANSMISSION
daemon = transmissionrpc.Client(
address=TRANSMISSION.server,
port=TRANSMISSION.port,
user=TRANSMISSION.user,
password=TRANSMISSION.password)
#!/bin/bash
declare -A oids
#upload
oids["sent-lo"]=".1.3.6.1.2.1.31.1.1.1.10.1"
oids["sent-eth0"]=".1.3.6.1.2.1.31.1.1.1.10.2"
oids["sent-vlan1"]=".1.3.6.1.2.1.31.1.1.1.10.5"
oids["sent-vlan2"]=".1.3.6.1.2.1.31.1.1.1.10.6"
oids["sent-eth1"]=".1.3.6.1.2.1.31.1.1.1.10.11"
@pettazz
pettazz / lvm-snapshot-backup.sh
Last active October 15, 2016 16:28
Use LVM snapshots to create a nightly backup of the whole root disk
#!/bin/bash
lvcreate -L2G -s -n /dev/alonso-vg/root-snapshot /dev/alonso-vg/root
dd if=/dev/alonso-vg/root-snapshot bs=16M status=progress | gzip -9 > /backup/alonso.nightly.gz
lvremove -f /dev/alonso-vg/root-snapshot
@pettazz
pettazz / lolpics.js
Created September 15, 2016 01:07
get all the urls from a wedding photo website because im lazy and i wanted to download them all
var urls = [];
var thumbs = $('.tab-frame-content .pg img.pv-img');
var doit = function(idx){
if(idx < thumbs.length){
var el = $(thumbs[idx]);
var link = el.parent('a');
link.trigger('mousedown');
var timeoutID = window.setTimeout(function(){
$('.pf-plane > .pv-ready .pv-inner > img.pv-img').each(function(){
var style = $(this).attr('style');
@pettazz
pettazz / spaghetti.py
Created April 27, 2016 20:43
really fuck up someone's plex usage with squid
#!/usr/bin/env python
import sys
BAD_PEOPLE = [
'192.168.1.118',
'192.168.1.119'
]
while True:
# squid writes stuff to us via stdin like this:
#!/bin/bash
UNRAR_LOG="/config/unrar.log"
UNRAR_DESTINATION="$TR_TORRENT_DIR"
echo "unrar for $TR_TORRENT_NAME, in $UNRAR_DESTINATION" >> $UNRAR_LOG
cd $UNRAR_DESTINATION;
if [ -n "$TR_TORRENT_NAME" ]; then
@pettazz
pettazz / transmission_wait.sh
Created April 6, 2015 19:18
make transmission wait for openvpn
#!/bin/bash
SERVICE=openvpn;
while [[ test $(ps -ef |grep ${SERVICE}) -gt 0 ]]
do
echo "waiting for openvpn..."
sleep 1m
done
@pettazz
pettazz / gist:85ac06d189107d1b00b1
Created February 4, 2015 17:51
Bootsnip form steps in 2.3.2
.bs-wizard {padding: 0 0 10px 3px; margin-left: 0px;}
.bs-wizard > .bs-wizard-step {margin: 0 -1px 0 0; padding: 0; position: relative;}
.bs-wizard > .bs-wizard-step + .bs-wizard-step {}
.bs-wizard > .bs-wizard-step .bs-wizard-stepnum {color: #595959; font-weight: bold; font-size: 16px; margin-bottom: 5px;}
.bs-wizard > .bs-wizard-step .bs-wizard-info {color: #999; font-size: 14px;}
.bs-wizard > .bs-wizard-step > .bs-wizard-dot {position: absolute; width: 30px; height: 30px; display: block; background: #fbe8aa; top: 45px; left: 50%; margin-top: -15px; margin-left: -15px; border-radius: 50%;}
.bs-wizard > .bs-wizard-step > .bs-wizard-dot:after {content: ' '; width: 14px; height: 14px; background: #fbbd19; border-radius: 50px; position: absolute; top: 8px; left: 8px; }
.bs-wizard > .bs-wizard-step > .progress {position: relative; border-radius: 0px; height: 8px; box-shadow: none; margin: 20px 0;}
.bs-wizard > .bs-wizard-step > .progress > .bar {width:0px; box-shadow: none; background: #fbe8aa; transition: wid
@pettazz
pettazz / reset_qcows.sh
Created February 19, 2013 21:48
Updated reset_vms version to use qemu qcows instead of VirtualBox
#!/bin/bash
function reset_vm {
echo "resetting $1..."
cd /home/pettazz/VMs/
if [ -a $1.pid ]
then
echo "killing existing VM pid:"
@pettazz
pettazz / reset_vms.sh
Last active November 9, 2020 09:01
bash script for deleting and re-cloning VirtualBox VMs from existing base images
#!/bin/bash
function reset_vm {
echo -e "\e[0;32m\n\nresetting $1...\n\n\e[00m"
echo -e "\e[0;34mpoweroff\e[00m"
vboxmanage controlvm "$1 - active" poweroff
sleep 5s
echo -e "\e[0;34munregister\e[00m"
vboxmanage unregistervm "$1 - active" --delete
echo -e "\e[0;34mclone\e[00m"