Skip to content

Instantly share code, notes, and snippets.

@esprengle
esprengle / bash_strict_mode.md
Created October 31, 2020 23:18 — forked from mohanpedala/bash_strict_mode.md
set -e, -u, -o pipefail explanation

set -e, -u, -o pipefail

The "set" lines These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing. With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.

set -euo pipefail is short for:

set -e
set -u
@esprengle
esprengle / SimpleHTTPServerWithUpload.py
Created September 6, 2020 07:09 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/usr/bin/env python
"""Simple HTTP Server With Upload.
This module builds on BaseHTTPServer by implementing the standard GET
and HEAD requests in a fairly straightforward manner.
"""
@esprengle
esprengle / Theme.py
Created June 28, 2020 03:55 — forked from ColdGrub1384/Theme.py
Import and export Pyto themes
"""
A script for importing and exporting Pyto themes.
"""
from rubicon.objc import ObjCClass, at
from console import clear
import sys
import base64
import sharing
@esprengle
esprengle / Theme.py
Created June 28, 2020 03:55 — forked from ColdGrub1384/Theme.py
Import and export Pyto themes
"""
A script for importing and exporting Pyto themes.
"""
from rubicon.objc import ObjCClass, at
from console import clear
import sys
import base64
import sharing
@esprengle
esprengle / gist:74622ebb36bab3e0f111351002d6d40c
Created June 28, 2020 03:48 — forked from benoitsan/gist:6278485
Export to Devonthink from Prizmo
-- Export to Devonthink without extra OCR within Devonthink (Script written by Benjamin Zeiss)
on run argv
if (count of argv) is greater than 0 then
repeat with theItem in argv
tell application id "com.devon-technologies.thinkpro2" to launch
try
set thePath to theItem as text
tell application id "com.devon-technologies.thinkpro2"
set theRecord to import thePath to incoming group
end tell
@esprengle
esprengle / RightClick.applescript
Created May 26, 2020 22:22 — forked from vitorgalvao/Right Click.applescript
Make right-clicking on OSX accessible via a keyboard shortcut.
(*
Even though a [native solution][1] exists, it still suffers from a big flaw: it right-clicks the place you cursor is, not what you’re selecting. This addresses that limitation.
You can install this as a [Finder Service, and later asign it a keyboard shortcut][2].
[1]: http://stackoverflow.com/questions/9171613/right-click-shortcut-for-mac-lion-os
[2]: http://www.macosxautomation.com/services/learn/tut01/index.html
*)
from sre_parse import Pattern, SubPattern, parse as sre_parse
from sre_compile import compile as sre_compile
from sre_constants import BRANCH, SUBPATTERN
class Scanner(object):
def __init__(self, tokens, flags=0):
subpatterns = []
pat = Pattern()
@esprengle
esprengle / Args.ipynb
Created May 6, 2020 06:31 — forked from gbishop/Args.ipynb
Allow arguments to be passed to notebooks via URL or command line.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@esprengle
esprengle / install_ipython.py
Created March 27, 2020 04:02 — forked from ColdGrub1384/install_ipython.py
A script for installing IPython on Pyto (11.1.12+)
"""
Installs IPython on Pyto.
Usage: Usage: import requests as r; exec(r.get('https://bit.ly/35iSbM1').content.decode())
"""
from pip import main as pip
import os.path
docs = os.path.expanduser("~/Documents")
@esprengle
esprengle / concat_images.py
Created February 14, 2020 04:03 — forked from njanakiev/concat_images.py
Concat images in a matrix grid with Python and PIL
import os
import random
from PIL import Image, ImageOps
def concat_images(image_paths, size, shape=None):
# Open images and resize them
width, height = size
images = map(Image.open, image_paths)
images = [ImageOps.fit(image, size, Image.ANTIALIAS)