Skip to content

Instantly share code, notes, and snippets.

@mattvh
mattvh / favicon.rb
Last active September 4, 2020 12:13
Discovering and saving favicons with Ruby
# 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
@mattvh
mattvh / imgur-tweetbot-api2.php
Created October 26, 2013 03:33
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/
<?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 / nudgemode.lua
Created July 27, 2015 06:19
Hammerspoon NudgeMode module
-- 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 / smstranscript.rb
Created July 7, 2017 02:52
Turns an iMessage conversation from an iPhone backup into an HTML transcript. MIT license.
# 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 / _layout.html
Created May 29, 2020 07:28
Baking Static Sites with Python and Jinja
<!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 / setup.py
Created June 7, 2020 07:00
Writing a GUI Application with Python and Py2App
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 / basic_decorator.py
Last active December 21, 2020 00:49
Example for Medium article "Python Decorators Explained"
def decorate(func):
print("Do something before func()")
func()
return func #return the original function, unmodified
@decorate
def hello():
print("Hello, world!")
@mattvh
mattvh / ipnotify.py
Last active November 12, 2021 20:22
# Raspberry Pi Pushover IP Notifier
# by Matt Harzewski (2021)
# License: MIT
#
# On system boot, this script checks to see if
# the IP address has changed, and sends a
# Pushover notification if it is different.
#
# Set the user and application tokens with your
# own from Pushover.net, and add the script to