Skip to content

Instantly share code, notes, and snippets.

View matthewhochler's full-sized avatar

Matt H matthewhochler

View GitHub Profile
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )

Is a useful one-liner which will give you the full directory name of the script no matter where it is being called from

These will work as long as the last component of the path used to find the script is not a symlink (directory links are OK). If you want to also resolve any links to the script itself, you need a multi-line solution:

SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
@matthewhochler
matthewhochler / Aurora-Profiles
Created October 2, 2018 07:00 — forked from throughnothing/Aurora-Profiles
Applescript to run multiple firefox instances with the profilemanager
do shell script "open -n -a aurora --args -profilemanager"
@matthewhochler
matthewhochler / merger.py
Created July 24, 2018 15:49 — forked from ericmjl/merger.py
A Python script for merging PDF files together.
"""
Author: Eric J. Ma
Purpose: To merge PDFs together in an automated fashion.
"""
import os
from PyPDF2 import PdfFileReader, PdfFileMerger
@matthewhochler
matthewhochler / itunesicon.rb
Created December 13, 2017 18:06 — forked from ttscoff/itunesicon.rb
Retrieve a 512 x 512px icon for an iOS app
#!/usr/bin/ruby
# encoding: utf-8
#
# Updated 2017-10-25:
# - Defaults to large size (512)
# - If ImageMagick is installed:
# - rounds the corners (copped from @bradjasper, https://github.com/bradjasper/Download-iTunes-Icon/blob/master/itunesicon.rb)
# - replace original with rounded version, converting to png if necessary
#
# Retrieve an iOS app icon at the highest available resolution
@matthewhochler
matthewhochler / sync_playlists_to_users.py
Created October 22, 2017 21:32 — forked from JonnyWong16/sync_playlists_to_users.py
Sync Plex playlists to shared users.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Description: Sync Plex playlists to shared users.
# Author: /u/SwiftPanda16
# Requires: plexapi, requests, xmltodict
import requests
import xmltodict
# This script adds a "Webclip" shortcut to your homescreen.
# The shortcut can be used to open a web page in full-screen mode,
# or to launch a custom URL (e.g. a third-party app).
# You'll be asked for a title, a URL, and an icon (from your camera roll)
import plistlib
import BaseHTTPServer
import webbrowser
import uuid
from io import BytesIO
app=$HOME/apps/nzbget-loop
cat > $app << EOF
#!/usr/bin/env bash
export TERM="xterm"
until ~/apps/nzbget/nzbget -s; do
echo "NZBGet crashed. Respawning.." >&2
sleep 1
done
EOF
chmod +x $app
@matthewhochler
matthewhochler / a-new-mac-setup.md
Created March 29, 2017 16:36 — forked from maxfenton/a-new-mac-setup.md
System setup stuff for a new mac

New computer setup

  • a/o 2016-05-21 *

--

Format the drive

  1. Restart with Cmd-R or Cmd-D
  2. Erase drive / 3x if second-hand
  3. Reinstall MacOS
@matthewhochler
matthewhochler / sync-repo.sh
Last active January 4, 2017 20:41
Sync RapidSOS repo with dev box
# sync-repo
# Dependencies:
# rsync (https://rsync.samba.org)
############################## BEGIN APP CONFIG ###############################
# You should only have to modify this section
# All paths are relative to your home
# Name of project to sync (used for notifications)
Public Function getRowNum(worksheetName, rowName, headerColumnNum) As Integer
Set worksheet = Worksheets(worksheetName)
rowNum = 0
lastRowNum = worksheet.Cells(worksheet.Rows.Count, headerColumnNum).End(xlup).Row
For rowLoopNum = 1 To lastRowNum
If worksheet.Cells(rowLoopNum, headerColumnNum).Value = rowName Then
rowNum = rowLoopNum
End If
Next rowLoopNum
getRowNum = rowNum