Skip to content

Instantly share code, notes, and snippets.

@twerp
twerp / restartAudio.bat
Created January 12, 2019 17:54 — forked from tigerhawkvok/restartAudio.bat
Restart Windows Audio Service (with admin permissions, if needed)
rem Written for buggy audio drivers that need to be restarted
rem In my case, the Claro 8.18 drivers bug out every once in a while on Windows 10, and need restarting to not sound poppy
@echo off
goto check_Permissions
:check_Permissions
echo Administrative permissions required to run this script. Checking...
net session >nul 2>&1
@twerp
twerp / functions.py
Last active March 13, 2024 14:58
Link-checker / link-reporter for dokuwiki text files (WIP; Python3.6)
import os
import requests
from collections import namedtuple
from pprint import pprint
from urllib.parse import urlparse
user_agent = ''
Link = namedtuple("Link", "url title")
@twerp
twerp / es6-component.html
Created January 31, 2018 17:20
Most simple React component using ES6 class & JSX
<div id="root"></div>
<script src="https://unpkg.com/react@16.2.0/umd/react.development.js"></script>
<script src="https://unpkg.com/react-dom@16.2.0/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
<script type="text/babel">
class Button extends React.Component {
constructor() {
super(); this.state = { count: 0 }
}
updateCount() {
@twerp
twerp / attic.py
Created December 11, 2017 18:14
WIP tool to "analyze" dokuwiki contents (currently prints out folders, pages and page revisions)
import os
import datetime
TOPFOLDER = r'..\wiki\data\attic'
class Folder():
_page_blacklist = ['sidebar']
blacklist = ['tag', 'testi', 'wiki']
@twerp
twerp / run.bat
Created November 2, 2017 13:45
Remove protection ("encryption") from a PDF doc
@echo off
FOR %%a IN (*.pdf) DO call unprotect.bat "%%a"
@twerp
twerp / clear_event_logs.cmd
Created November 2, 2017 13:40
Clear Windows 8+ event logs (use at your own risk)
@for /f "delims=," %%i in ( 'wevtutil el' ) do wevtutil cl "%%i" >NUL 2>&1
@twerp
twerp / expand.bat
Created November 2, 2017 13:38
Use mutool (from mupdf) to expand ("clean") a PDF doc
mutool clean -d %1 "%~n1-cleaned.pdf"
@twerp
twerp / lofi.bat
Created November 2, 2017 13:34
Use GhostScript (for Windows) to optimize a PDF doc
gswin64c.exe -o "%~n1-optimized.pdf" -sDEVICE=pdfwrite -dPDFSETTINGS=/default %1

Design Recipes

In this course, we teach an approach to program design based on design recipes. Each recipe is applicable to certain problems, and systematizes the process of designing solutions to those problems.

There are three core recipes that are used most frequently. The templating recipes are used as part of the design of every data definition and function. Abstraction recipes are used to reduce redundancy in code.

You can also download a condensed version of some of the design recipes here for easy reference.

Core Recipes

@twerp
twerp / pycdump.py
Created November 17, 2016 17:34 — forked from anonymous/pycdump.py
Dump .pyc file (Python 3.5 version)
#
# read a .pyc file and pretty-print it
#
# copied from http://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html
# and updated to Python 3.5 (Nov 10th 2015)