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 time | |
from contextlib import suppress | |
if os.name == 'nt': | |
from ctypes import windll, wintypes, byref | |
def set_creation_time(path, timestamp): | |
"""Set the creation time of files in Windows. |
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
"""Qt script editor for Python with syntax highlighting. | |
Author: Peter Hunt | |
Updated: 5/9/2019 | |
""" | |
try: | |
import builtins | |
except ImportError: | |
import __builtin__ as builtins |
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
"""Find the missing lambda cache locations in Half Life 2.""" | |
import os | |
# Change this line if you have games installed elsewhere | |
STEAMAPPS = 'C:/Program Files (x86)/Steam/steamapps/common/' | |
GAMESTATE = os.path.join(STEAMAPPS, 'Half-Life 2/hl2/gamestate.txt') | |
# Locations from https://steamcommunity.com/sharedfiles/filedetails/?id=145616679 |
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() |
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
# 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
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
# 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
"""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',) |
OlderNewer