Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Harzewski mattvh

View GitHub Profile
@mattvh
mattvh / basic_decorator.py
Last active Dec 21, 2020
Example for Medium article "Python Decorators Explained"
View basic_decorator.py
def decorate(func):
print("Do something before func()")
func()
return func #return the original function, unmodified
@decorate
def hello():
print("Hello, world!")
@mattvh
mattvh / setup.py
Created Jun 7, 2020
Writing a GUI Application with Python and Py2App
View setup.py
from setuptools import setup
APP = ['subreddit.py']
DATA_FILES = []
OPTIONS = {
'argv_emulation': True,
'site_packages': True,
#'iconfile': 'appicon.icns',
'packages': ['wx', 'requests'],
'plist': {
@mattvh
mattvh / _layout.html
Created May 29, 2020
Baking Static Sites with Python and Jinja
View _layout.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>{{ title }}</title>
<link rel="stylesheet" href="static/style.css">
</head>
<body>
<div class="container">
@mattvh
mattvh / smstranscript.rb
Created Jul 7, 2017
Turns an iMessage conversation from an iPhone backup into an HTML transcript. MIT license.
View smstranscript.rb
# Converts an iPhone SMS.db file into HTML
# Mac: Library > Application Support > MobileSync > Backup
# Windows: C:\Users\<user name>\AppData\Roaming\Apple Computer\MobileSync\Backup
# Find the folder with the most recently modified date and open it.
# Locate the 3d0d7e5fb2ce288813306e4d4636395e047a3d28 file and copy it to the location of this script.
# Rename the file to "db.sqlite"
# Replace HANDLE_GOES_HERE with the phone number/etc identifying the other party in the DB.
# Run the script.
require "sqlite3"
@mattvh
mattvh / nudgemode.lua
Created Jul 27, 2015
Hammerspoon NudgeMode module
View nudgemode.lua
-- Window nudging and resizing with modal shortcuts
-- Initialize with desired mode keybind:
-- windowmode.init({"cmd", "alt", "ctrl", "shift"}, "m")
-- Nudge window with arrows, resize with shift and arrows
-- HJKL is also supported
-- Space or return exits nudge mode
-- ------------------------------------------------------
-- http://github.com/mattvh
@mattvh
mattvh / imgur-tweetbot-api2.php
Created Oct 26, 2013
This is the original code from my tutorial on how to use the Imgur API with Tweetbot for Mac. Imgur has since iterated their API, which requires a new script. I'm just archiving the old one here, while I update the post for version 3. http://www.webmaster-source.com/2012/10/20/adding-imgur-support-to-tweetbot-for-mac/
View imgur-tweetbot-api2.php
<?php
class TweetbotImgurEndpoint {
private $api_key;
private $api_url = "http://api.imgur.com/2/upload.json";
private $file_temp_location;
private $file_name;
@mattvh
mattvh / favicon.rb
Last active Sep 4, 2020
Discovering and saving favicons with Ruby
View favicon.rb
# by Matt Harzewski
# Read more: http://www.webmaster-source.com/2013/09/25/finding-a-websites-favicon-with-ruby/
require "httparty"
require "nokogiri"
require "base64"
class Favicon