Skip to content

Instantly share code, notes, and snippets.

@ntrepid8
ntrepid8 / bluray-tips.md
Created May 1, 2017 01:05
How to play video disks on Ubuntu 16.04

How to play movie disks on Ubuntu 16.04

To remind me how I got video playback workin on Ubuntu 16.04 for video disks.

DVD

$ sudo apt install vlc libdvd-pkg
$ sudo dpkg-reconfigure libdvd-pkg
@ntrepid8
ntrepid8 / cron_speedtest.sh
Created June 28, 2017 02:18
Script to run speedtest-cli via cron and log the results
#!/usr/bin/env bash
LOG_PATH="/home/$(whoami)/log/speedtest.log"
if result=$(/usr/bin/speedtest --simple); then
parsed_result=$(printf "${result}\"" | sed ':a;N;$!ba;s/\n/" /g' | sed 's/: /="/g')
printf "[$(date)] ${parsed_result}\n" >> "${LOG_PATH}"
else
printf "[$(date)] error\n" >> "${LOG_PATH}"
exit 1
@ntrepid8
ntrepid8 / parse_speedtest_simple.py
Last active June 28, 2017 03:11
Simple python script to parse speedtest-cli --simple output into a CSV line
#!/usr/bin/env python
import fileinput
import datetime
input_lines = []
for line in fileinput.input():
input_lines.append(line)
ping_key,ping_val,ping_unit = input_lines[0].split(" ")
download_key,download_val,download_unit = input_lines[1].split(" ")
@ntrepid8
ntrepid8 / cron_speedtest_csv.sh
Last active June 28, 2017 03:19
Shell script to use with speedtest-cli and parse_speedtest_simple.py
#!/usr/bin/env bash
DATE_TAG="$(date -u +"%Y")-$(date -u +"%m")"
CSV_PATH="/home/$(whoami)/log/speedtest.$(hostname).${DATE_TAG}.csv"
LOG_PATH="/home/$(whoami)/log/speedtest.$(hostname).${DATE_TAG}.csv.log"
# ensure the path exists
mkdir -p $(dirname "${CSV_PATH}")
# add the header row if the file does not exist
@ntrepid8
ntrepid8 / lxc_lxd_notes.md
Last active February 22, 2022 15:11
LXC/LXD Notes
@ntrepid8
ntrepid8 / rsync_ssh.md
Created November 29, 2017 15:09
Rsync via SSH

Rsync via SSH

Use rsync via ssh to transfer large files or groups of files. It even has a progess bar :)

Push file(s):

$ rsync -avz -e "ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" --progress --delete \
"$LOCAL_PATH" "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
@ntrepid8
ntrepid8 / tar_xz_tips.md
Last active August 20, 2022 14:04
Create tar.xz file with threads and progress bar

tar xz tips

Compress a directory using multiple threads and show a progress bar with this script:

#!/usr/bin/env bash

# example: tar_cJf.sh ./directory > directory.tar.xz

SOURCE="$1"
@ntrepid8
ntrepid8 / sublp.py
Created January 10, 2018 16:57
Python script to find a .sublime-project file in the current directory and launch the project in Sublime Text.
#!/usr/bin/env python3
import os
import subprocess
cwd = os.getcwd()
file_list = [f for f in os.listdir(cwd) if f.endswith('.sublime-project')]
fl_len = len(file_list)
if fl_len == 0:
print("sublime-project file not found")