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 os | |
import re | |
import win32crypt # Requires pywin32 package | |
WORKBENCH_REGEX = re.compile( | |
'(?P<dbm>[A-z]+)' | |
'@' | |
'(?P<host>[A-z0-9._-]+)' | |
':' |
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 csv | |
import json | |
# Open the JSON file and read its contents | |
print('Loading data...') | |
with open('Records.json') as json_file: | |
data = json.load(json_file) | |
# Create a CSV file and write the headers | |
print('Processing data...') |
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
"""This is a basic script I mashed together to download all the media on a users profile. | |
Nothing else I found seemed to work well, so I added support for all the media types I came across. | |
The code isn't particularly clean or optimised, it just gets the job done. | |
Usage: | |
UserDownloader(username).download() | |
It will download to `current_dir/username/filename.ext`. | |
An SQLite database saved in the same folder is used to ignore duplicate urls and file hashes. |
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
# Very small changes to an existing script, copying here for personal use | |
# Run file from next to the .git folder | |
import subprocess, shlex | |
import sys, os.path | |
os.chdir(os.path.dirname(__file__)) | |
filelist = set() | |
for path in (sys.argv[1:] or [os.getcwd()]): |
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
CREATE FUNCTION `format_bytes` (val float) | |
RETURNS varchar(20) | |
DETERMINISTIC | |
CONTAINS SQL | |
BEGIN | |
DECLARE pw smallint; | |
IF val < 1024 THEN | |
return CONCAT(val, ' B'); | |
END IF; | |
SET pw = LEAST(7, FLOOR(LOG(val) / LOG(1024))); |
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
# Quick script to mirror folders using Google Drive File Sync. | |
# Built for transferring VR game saves from a laptop to my main PC. | |
# For example, to keep Firefox in sync, create a "G:/My Drive/Firefox" | |
# directory, copy this script and create two batch files: | |
# upload.bat: py quicksync.py upload %APPDATA%/Mozilla/Firefox | |
# download.bat: py quicksync.py download %APPDATA%/Mozilla/Firefox | |
import sys |
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
"""Get import dependencies using PyInstaller. | |
The node types can be used to check for instances. | |
A brief description of the main ones are below: | |
MissingModule: An imported module that cannot be found. | |
Attributes: | |
identifier (str) | |
Example: | |
MissingModule('invalid.module',) |
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
"""Convert numbers to the Cistercian monk numeral system. | |
https://en.wikipedia.org/wiki/The_Ciphers_of_the_Monks | |
""" | |
import numpy as np | |
def horizontal_reverse(n): | |
"""Horizontally reverse a number index.""" |
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
"""Grab the test count and grader setup from the EdX Python exercises.""" | |
import os | |
import sys | |
mod = __import__(sys.argv[1][:-3]) | |
def __fn__(*args, **kwargs): | |
print('Number of tests:', len(mod.grader.tests())) | |
print() |
NewerOlder