Skip to content

Instantly share code, notes, and snippets.

@srob650
srob650 / freebsd-qemu-xhyve-mac-os-x-virtual-machine.md
Created September 26, 2017 03:12 — forked from zg/freebsd-qemu-xhyve-mac-os-x-virtual-machine.md
Create FreeBSD virtual machine using qemu. Run the VM using xhyve.

TL;DR

  • Create 10GB FreeBSD image using QEMU.
  • Run the VM using xhyve.
  • Mount host directory.
  • Resize the image.

Requisites

@srob650
srob650 / plex_token.py
Created September 22, 2017 03:44
Retrieve Plex token
'''Enter Plex username and password and run the script to retrieve your Plex token'''
import httplib, urllib, base64
username = ""
password = ""
base64string = base64.encodestring('%s:%s' % (username, password)).replace('\n', '')
txdata = ""
headers={'Authorization': "Basic %s" % base64string,
'X-Plex-Client-Identifier': "Test script",
@srob650
srob650 / filesystem_db.py
Created September 22, 2017 03:36
Build a sqlite database of all files under a given directory.
'''
Build a sqlite database of all files under a given directory.
Usage:
python filesystem_db.py /path/to/directory
'''
import os
import sys
@srob650
srob650 / maintenance_onEdit.gs
Last active August 2, 2017 06:05
Automatically sort Google Sheets by "priority" and "date recorded", and automatically move rows to archive once date entered into "date completed".
// Constants
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var activeSheet= spreadsheet.getActiveSheet()
var cell = activeSheet.getActiveCell();
// Sorting
var rangeToSort = activeSheet.getRange("A3:K");
var sortOrder = [{column: 4, ascending: false}, // Date Completed
{column: 1, ascending: true}, // Priority
{column: 3, ascending: true},] // Date Recorded
@srob650
srob650 / create_virtualenv.sh
Last active June 3, 2018 19:24
Download Python 3.6.1 and install it into a standalone virtualenv
if [ $EUID != 0 ]; then
sudo "$0" "$@"
exit $?
fi
BASE_DIR=$PWD
# Name your environment:
ENV=.env
mkdir $ENV
@srob650
srob650 / yt-audio.sh
Last active April 21, 2017 18:16
youtube-dl command for audio only - requires ffmpeg
yt-audio() {
youtube-dl -f bestaudio --restrict-filenames -o "~/Desktop/%(title)s.%(ext)s" "$1" --exec 'ffmpeg -i {} {}.wav && rm {}'
}
@srob650
srob650 / du_plus.sh
Created April 8, 2017 04:45
Disk Usage by folder for BASH
du-plus() {
du -k | sort -n | perl -ne 'if ( /^(\d+)\s+(.*$)/){$l=log($1+.1);$m=int($l/log(1024)); printf ("%6.1f\t%s\t%25s %s\n",($1/(2**(10*$m))),(("K","M","G","T","P")[$m]),"*"x (1.5*$l),$2);}'
}
@srob650
srob650 / ping_all.sh
Created April 3, 2017 21:17
Ping all IP's in range
x=0
while [ "$x" -lt "255" ]; do
ping -c 1 192.168.1.$x &
x=$(expr $x + 1)
done
@srob650
srob650 / weeks_episodes.py
Last active January 22, 2017 01:45
[pytvmaze] Get all episodes for show for next 7 days
import datetime
import pytvmaze
today = datetime.datetime.now()
week = today + datetime.timedelta(days=7)
tvm = pytvmaze.TVMaze()
# Edit maze_id for desired show
s = tvm.get_show(maze_id=279)
@srob650
srob650 / gitlog.txt
Created October 10, 2016 01:40
Pretty decorated git log alias for terminal
gitlog='git log --graph --abbrev-commit --decorate --date=relative --format=format:'\''%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)'\'' --all'