Skip to content

Instantly share code, notes, and snippets.

View jorng's full-sized avatar

Rob Prentiss jorng

View GitHub Profile

Keybase proof

I hereby claim:

  • I am jorng on github.
  • I am robprentiss (https://keybase.io/robprentiss) on keybase.
  • I have a public key ASDCDcRI4mfcEiUn6l4-2JVtNvZN9a2ZguDNlOU5_expDQo

To claim this, I am signing this object:

@jorng
jorng / linode-stackscript-gitea.sh
Last active April 25, 2020 11:24
Linode Stackscript for setting up a Gitea server
#!/bin/bash
# This block defines the variables the user of the script needs to input
# when deploying using this script.
#
#<UDF name="hostname" label="The hostname for the new Linode." default="gitea">
#<UDF name="FQDN" label="The new Linode's Fully Qualified Domain Name">
#<UDF name="POSTGRES_PASSWORD" label="The password to use for PostgreSQL">
#<UDF name="GITEA_VERSION" label="The Gitea Version to install" default="1.5" oneof="1.4.0,1.4.1,1.4.2,1.4.3,1.5">
# This sets the variable $IPADDR to the IP address the new Linode receives.
@jorng
jorng / base64regex.py
Created June 24, 2016 19:52
(Python) Get a compiled regex to match a base64 string for a given hashing algorithm
import re
from math import ceil
import hashlib
def base64Regex(byteLength):
padLength = (3 - (byteLength % 3)) if (byteLength % 3) > 0 else 0
strLength = int(ceil(byteLength / 3.)) * 4 - padLength
padding = '=' * padLength
regexString = '[a-zA-Z0-9+/]{{{strLength}}}{padding}'.format(**locals())
@jorng
jorng / downloadWithProgress.py
Last active April 15, 2017 00:07
Function to download a file from a specified URL while outputting a progress bar to stdout.
#! /usr/bin/python
def downloadFileWithProgress(url, downloadFolder='./', sha1=None, chunk_size=8192):
import requests, sys
"""
Function to download a file from the specified URL.
Outputs a basic progress bar and download stats to the CLI.
Optionally downloads to a specified download folder, and checks the SHA1 checksum of the file.
Chunk size can also be specified, to control the download.
@jorng
jorng / progressBar.applescript
Last active July 7, 2019 13:17
Simple AppleScript progress bar demo for Yosemite
set progress description to "A simple progress indicator"
set progress additional description to "Preparing…"
set progress total steps to -1
delay 5
set progress total steps to 100
repeat with i from 1 to 100
try
set progress additional description to "I am on step " & i
@jorng
jorng / enableNetBootStorage.sh
Last active August 29, 2015 14:03
A script to enable NetBoot storage settings for a specified volume. Replicates using Server.app to select 'Images & Client Data' for a specified volume. Takes one parameter: the volume to enable. If no parameter is provided, it will enable the root volume for NetBoot.
#!/bin/bash
OSXVersion=$(sw_vers -buildVersion)
if [[ "$OSXVersion" < "12A" ]]; then
ServerAdminPath="/usr/sbin/serveradmin"
else
ServerAdminPath="/Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin"
fi
if [ ! -e $ServerAdminPath ]; then
echo "Unable to find 'serveradmin' tool. Is Server.app in the Applications folder?"
exit 1