Skip to content

Instantly share code, notes, and snippets.

@krets
krets / timer.py
Last active January 25, 2024 11:29
Multi-use timer object
import time
import logging
class Timer:
"""
A Timer helper
This object can be used as an object, context or decorator.
Messages can be collected via logging by using the report() method.
@krets
krets / amazon_product_url.js
Last active July 15, 2021 19:12
Amazon Product URL shortened (Bookmarklet)
javascript:(function(){prompt("short url", window.location.href.replace(/^(.*:\/\/[^\/]+).*\/(dp|gp\/product)\/([^\/]+).*/, "$1/dp/$3"))})()
""" Test for drawing base64 image strings for job progress
Example Job:
{
'comment': '',
'maxslots': 0,
'numblocked': 0,
'spoolcwd': '/home/freddie/unitard,
'numerror': 0,
'aftertime': None,
@krets
krets / QtSiteConfig.py
Created January 30, 2018 15:28
Qt.py - QWebEngineView
""" Add the QWebEngineView
Requires Qt.py >=1.1.0
"""
import logging
LOG = logging.getLogger('tx.QtSiteConfig')
def update_members(members):
LOG.debug("update_members")
members['QtWebEngineWidgets'] = ["QWebEngineView","QWebEnginePage"]
@krets
krets / slack_leave_bd_channels.py
Last active July 15, 2022 17:39
Quick script to leave a bunch of slack channels with the "bd-" prefix.
#!/usr/bin/env python
import argparse
import requests
import logging
LOG = logging.getLogger("slack_leaver")
class JSONRest(object):
def __init__(self, base_url):
if [ -r ~/.ssh/known_hosts ]; then
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e 's/,.*//g' | uniq | grep -v "\["`;)" ssh
fi
@krets
krets / rvFlipBook.py
Last active September 15, 2019 01:01
RV Flipbook for Nuke (with binary discovery)
# http://docs.thefoundry.co.uk/nuke/63/pythondevguide/flipbook.html
# Copyright (c) 2010 The Foundry Visionmongers Ltd. All Rights Reserved.
import glob
import os.path
import platform
import re
import subprocess
import sys
import thread
@krets
krets / update_wiretap_anon_usergroup.py
Last active August 29, 2015 14:09
Update Wiretap Anonymous User & Group
import os
import sys
import grp
import pwd
import re
import tempfile
import shutil
import getpass
import logging
import sys
import getpass
sentry_url = 'http://<hash>:<hash>@sentry-server.local/1'
try:
import raven
RAVEN_CLIENT = raven.Client(sentry_url)
RAVEN_CLIENT.tags_context({'user':getpass.getuser()})
except:
RAVEN_CLIENT = None
@krets
krets / Clipboard Flip Slashes
Last active August 29, 2015 14:00
ach, whitespace.
"""
Flip slashes in ClipBoard
Now using Tk, so it should be cross-platform.
http://stackoverflow.com/questions/579687
"""
from Tkinter import Tk
w = Tk() # create window object
w.withdraw() # hide window from view.