View docx-find-replace.py
import docx | |
# general routine for finding and replacing text in a docx | |
def docx_find_replace_text(search_text, replace_text, paragraphs): | |
"""Replace strings and retain the same style. | |
The text to be replaced can be split over several runs so | |
search through, identify which runs need to have text replaced | |
then replace the text in those identified | |
""" |
View python-docx-replace-text-and-retain-style.py
def docx_replace(doc, data): | |
paragraphs = list(doc.paragraphs) | |
for t in doc.tables: | |
for row in t.rows: | |
for cell in row.cells: | |
for paragraph in cell.paragraphs: | |
paragraphs.append(paragraph) | |
for p in paragraphs: | |
for key, val in data.items(): | |
key_name = '${{{}}}'.format(key) # use placeholders in the form ${PlaceholderName} |
View monkey-patch-python-docx-to-load--dotx.py
# Monkey-patch Document to load a Word Template .dotx | |
# tested on python-docx v0.8.10 and based on https://github.com/python-openxml/python-docx/issues/363 | |
import docx | |
from docx.opc.constants import CONTENT_TYPE | |
from docx.package import Package | |
from docx.api import _default_docx_path | |
from docx.opc.part import PartFactory | |
from docx.parts.document import DocumentPart |
View gist:14acbc9165121047cf106ca32379c854
# Xcode cli tools must be installed first, they have to be reinstalled after macOS version upgrades | |
xcode-select --install | |
# make sure Homebrew is up to date | |
brew update && brew upgrade | |
# change the version to be whichever one is failing | |
CFLAGS="-I$(xcrun --show-sdk-path)/usr/include" pyenv install -v 3.7.2 |
View make-el-capital-bootable-iso.sh
# found here: https://forums.macrumors.com/threads/el-capitan-bootable-dvd.1923931/#post-22036604 | |
hdiutil attach /Applications/Install\ OS\ X\ El\ Capitan.app/Contents/SharedSupport/InstallESD.dmg -noverify -nobrowse -mountpoint /Volumes/install_app | |
hdiutil convert /Volumes/install_app/BaseSystem.dmg -format UDSP -o /tmp/El\ Capitan | |
hdiutil resize -size 9g /tmp/El\ Capitan.sparseimage | |
hdiutil attach /tmp/El\ Capitan.sparseimage -noverify -nobrowse -mountpoint /Volumes/install_build | |
rm /Volumes/install_build/System/Installation/Packages | |
cp -rp /Volumes/install_app/Packages /Volumes/install_build/System/Installation/ | |
cp -rp /Volumes/install_app/BaseSystem.chunklist /Volumes/install_build | |
cp -rp /Volumes/install_app/BaseSystem.dmg /Volumes/install_build |
View .screenrc
# $Id: screenrc,v 1.15 2003/10/08 11:39:03 zal Exp $ | |
# | |
# /etc/screenrc | |
# | |
# This is the system wide screenrc. | |
# | |
# You can use this file to change the default behavior of screen system wide | |
# or copy it to ~/.screenrc and use it as a starting point for your own | |
# settings. | |
# |
View xlsx_dict_reader.py
from openpyxl import load_workbook | |
def XLSXDictReader(f): | |
book = load_workbook(f) | |
sheet = book.active | |
rows = sheet.max_row | |
cols = sheet.max_column | |
headers = dict((i, sheet.cell(row=1, column=i).value) for i in range(1, cols)) | |
def item(i, j): | |
return (sheet.cell(row=1, column=j).value, sheet.cell(row=i, column=j).value) |
View restic-backup-windows-vss.ps1
# Windows PowerShell Script to use restic to backup files using the Volume Shadow Copy Service, allowing | |
# that are in use to be backed up. The script must be run with elevated privileges. | |
# The Volume Shadow Copy Service must be enabled for the disk volume that contains the files to be backed up. | |
# | |
# credit: https://github.com/turnkey-commerce | |
# | |
# Parameters | |
$resticExe = 'C:\Users\Username\go\bin\restic.exe' | |
$resticRepository = '\\SYNOLOGY212J\backups\restic-workstation' | |
$rootVolume = "C:\" |
View flac2alac.sh
#!/bin/sh | |
ffmpeg -i “$1″ -acodec alac “`basename “$1″ .flac`.m4a” \ | |
-metadata title=\”"$(metaflac –show-tag=TITLE “$1″ | sed ‘s/title=//g’)”\” \ | |
-metadata author=\”"$(metaflac –show-tag=ARTIST “$1″ | sed ‘s/artist=//g’)”\” \ | |
-metadata album=\”"$(metaflac –show-tag=ALBUM “$1″ | sed ‘s/album=//g’)”\” \ | |
-metadata year=\”"$(metaflac –show-tag=DATE “$1″ | sed ‘s/date=//g’)”\” \ | |
-metadata track=\”"$(metaflac –show-tag=TRACKNUMBER “$1″ | sed ‘s/tracknumber=//g’)”\” \ | |
-metadata genre=\”"$(metaflac –show-tag=GENRE “$1″ | sed ‘s/genre=//g’)”\” |
View wine-app-with-mac-driver.script
on run | |
--edit this to be the correct location and file to run (typically only edit after the "drive_c") | |
set toRun to "$WINEPREFIX/drive_c/Program Files/MyProgram/MyProgramName.exe" | |
--edit winePrefix if you are not using the default prefix | |
set winePrefix to "$HOME/.wine" | |
--edit wineLocation if your wine install is not the default location | |
set wineLocation to "/usr/local/bin" |
NewerOlder