Skip to content

Instantly share code, notes, and snippets.

import sys
debug = True
def exceptionHandler(exception_type, exception, traceback, debug_hook=sys.excepthook):
'''Print user friendly error messages normally, full traceback if DEBUG on.
Adapted from http://stackoverflow.com/questions/27674602/hide-traceback-unless-a-debug-flag-is-set
'''
if debug:
print('\n*** Error:')
# raise
@Dulani
Dulani / scratch_18_pickle.py
Created November 1, 2019 16:00
Simple example: Python pickle
# Save a dictionary into a pickle file.
# https://wiki.python.org/moin/UsingPickle
import pickle
favorite_color = { "lion": "yellow", "kitty": "red" }
pickle.dump( favorite_color, open( "test.pickle", "wb" ))
# Load the dictionary back from the pickle file.
more_favorite_colors = pickle.load(open( "test.pickle", "rb" ))
# favorite_color is now { "lion": "yellow", "kitty": "red" }
@Dulani
Dulani / markdown-details-collapsible.md
Created February 12, 2020 19:05 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@Dulani
Dulani / stitch_transcript.py
Created June 25, 2020 03:10 — forked from turtlemonvh/stitch_transcript.py
Stitch together AWS Transcribe transcripts, including speaker labels
#!/usr/bin/env python
"""
Stitch multiple files worth of AWS transcripts together.
Does not attempt to match speakers across filesm but does label all speaker changes.
Usage:
python stitch_transcript.py *.mp3.json -o out.txt
See blog post: http://turtlemonvh.github.io/aws-transcribe-for-long-zoom-meetings.html
@Dulani
Dulani / instal_python-opencv_rpi3.md
Created July 18, 2020 06:07
Solutions to pip installing python-opencv on Raspbian Buster on an RPi 3
(*
Use AppleScript to repeatedly click some part of the screen on a Mac 50 times with a 2 second pause between clicks (use on poorly designed applications that don't let you repeat a certain action).
https://apple.stackexchange.com/questions/266784/how-do-i-make-the-mouse-click-at-current-location-using-applescript
Comment: To supplement @jksoegaard's answer: one can also find cursor positions using "Screenshot" tool, which may be activated by Cmd+Shift+4 shortcut. Then just point the cursor to any area and remember the numbers that is shown near the pointer.
*)
repeat 50 times
tell application "System Events"
click at {1073, 373}
@Dulani
Dulani / Penguin Linux Export Path.sh
Created December 21, 2020 06:05
Add to .bashrc to find Python binaries in the PATH environment variable
# Add to .bashrc for Python binaries:
# Python and pip3
export PATH="${PATH}:/home/{username}/.local/bin"
@Dulani
Dulani / example.md
Created April 7, 2021 02:12 — forked from ericclemmons/example.md
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot noisey logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 Summary Goes Here