Skip to content

Instantly share code, notes, and snippets.

View rho333's full-sized avatar

rho333 rho333

  • Sydney, Australia
View GitHub Profile
@rho333
rho333 / mount_volume.md
Last active September 1, 2021 06:21
Mount ReadyNAS OS encrypted volume remotely over SSH

Remotely mounting a ReadyNAS volume over SSH

This is a not a shell script, run these commands manually. Tested working with ReadyNAS OS 6.10.4 Hotfix 1.

Procedure

Find your volume name:

ls /dev/md
@rho333
rho333 / j2render.py
Created April 25, 2018 23:13
j2render - Python script to render Jinja2 templates on the CLI
#!/usr/local/bin/python
# To get all dependencies for this, run:
# pip install PyYAML jinja2
# To install, just copy it to /usr/local/bin.
import sys, os
import jinja2
import yaml
@rho333
rho333 / phone_number_internationalisation.py
Last active September 1, 2016 04:42
Internationalises valid phone numbers given for a particular country, to E.164
import re
# Dial-in prefixes
international_prefixes = {
'FR': "33", # France
'AU': "61", # Australia
'NZ': "64", # New Zealand
'UK': "44", # United Kingdon
'US': "1", # United States
'CA': "1", # Canada
@rho333
rho333 / mac_model_to_type.py
Last active December 5, 2022 14:35
Convert Mac model strings into general category
# Returns dictionary mapping lowercase model strings (e.g. 'macbookpro11,3')
# to a general category (e.g. "MacBook Pro (15-inch)").
# Exact model names can be modified.
# @author Richard Hofman
#
def model_to_type_dict():
type_to_model = {'Macbook Pro (Retina, 13-inch)': ['MacBookPro10,2', 'MacBookPro11,1', 'MacbookPro12,1'],
'MacBook Pro (13-inch)': ['MacBookPro9,2', 'MacBookPro8,1', 'MacBookPro7,1', 'MacBookPro5,5'],
'MacBook Pro (Retina, 15-inch)': ['MacbookPro11,4', 'MacbookPro11,5', 'MacBookPro11,2', 'MacBookPro11,3', 'MacBookPro10,1'],
'MacBook Pro (15-inch)': ['MacBookPro9,1', 'MacBookPro8,2', 'MacBookPro6,2', 'MacBookPro5,3', 'MacBookPro5,1', 'MacBookPro4,1', 'MacBookPro3,1', 'MacBookPro2,2', 'MacBookPro1,1'],
@rho333
rho333 / bulk_rename.py
Created November 21, 2015 13:05
Useful script for bulk renaming files on the basis of their type.
# Small script which uses the "file" command to
# determine the types of all files in the current
# directory with names starting with '#'.
#
# It then sets the file extension as appropriate.
# Written to recover data from a badly damaged filesystem's
# lost&found folder, after testdisk.
#
# Author: Richard Hofman, 2015
#
@rho333
rho333 / vf_usage_tracker.py
Created August 2, 2014 05:39
Simple Vodafone NZ usage scraper/tracker
# Simple Python script to fetch usage data for Vodafone NZ customers and push
# some summary stats to their mobile phones/tablets via Boxcar.
#
# Disclaimer: I in no way guarantee the security, continued functionality or support of this software.
# I am in no way affiliated with Vodafone NZ. This software is licensed under the MIT License.
#
# -----------------------
#
# The MIT License (MIT)
#