This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#------------------------------------------------------------------------------- | |
# Name: example-TimedRotatingFileHandler.py | |
# Purpose: Write log using TimedRotatingFileHandler | |
# Author: Adrian Jones | |
# Created: 2012-05-25 | |
# | |
# TimedRotatingFileHandler: from handler.py source: | |
# Current 'when' events supported: | |
# S - Seconds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# vim: ft=python ts=4 sw=4 expandtab | |
# | |
# Copyright (c) 2013 Reed Kraft-Murphy <reed@reedmurphy.net> | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy | |
# of this software and associated documentation files (the "Software"), to deal | |
# in the Software without restriction, including without limitation the rights | |
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
# copies of the Software, and to permit persons to whom the Software is |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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:\" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
SET stPath=C:\Program Files\Sublime Text\sublime_text.exe | |
:: add it for all file types | |
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f | |
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /t REG_EXPAND_SZ /v "Icon" /d "%stPath%,0" /f | |
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /t REG_SZ /v "" /d "%stPath% \"%%1\"" /f | |
:: add it for directories | |
@reg add "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /t REG_SZ /v "" /d "Open with Sublime Text" /f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: delete all file types | |
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /f | |
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text" /f | |
@reg delete "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command" /f | |
:: delete it for directory | |
@reg delete "HKEY_CLASSES_ROOT\Directory\shell\Open with Sublime Text" /f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
NewerOlder