Skip to content

Instantly share code, notes, and snippets.

View tylerhall's full-sized avatar

Tyler Hall tylerhall

View GitHub Profile
tell application "Mail"
set theSelection to selection
set theMessage to item 1 of theSelection
set theSender to sender of theMessage
make new message viewer
activate
end tell
tell application "System Events"
keystroke "f" using {command down, option down}
@tylerhall
tylerhall / PhotosImporter.scpt
Last active April 22, 2019 21:16
AppleScript to rsync images from a remote server and import them into Photos.app. Cleans up after itself.
# Download photos from the remote server
do shell script "rsync -avz --delete -e 'ssh -p 22' user@domain.com:/path/to/photos/ /Users/username/Pictures/SomeFolder/"
set folderPath to alias "Users:username:Pictures:SomeFolder"
set imageList to getImageList(folderPath)
# Import the list of photos into Photos.app
if number of items in imageList is greater than 0 then
tell application "Photos"
activate
@tylerhall
tylerhall / email-to-github.php
Created April 8, 2019 18:10
Parse an inbound email webhook and create a new GitHub issue containing any attached images.
<?PHP
// Note: This script relies on Postmark to parse the email's contents into JSON.
// More info here: https://postmarkapp.com/
$post = trim(file_get_contents('php://input'));
$email = json_decode($post);
if(is_null($email)) {
exit;
}
<?PHP
$post = trim(file_get_contents('php://input'));
$dict = json_decode($post);
// Only process emails starting with our kids' names since they're the ones with photos/videos. All other service emails should be ignored...
if(substr($dict->Subject, 0, strlen("Kid #1's Name")) == "Kid #1's Name" || substr($dict->Subject, 0, strlen("Kid #2's Name")) == "Kid #2's Name") {
$html = $dict->HtmlBody;
if(preg_match('!href=[\'"](https?://www.domain.com/m/p/[a-zA-Z0-9]+)[\'"]!', $html, $matches) == 1) {
$img_url = $matches[1] . '?d=t';
$img_data = file_get_contents($img_url);
@tylerhall
tylerhall / github-backup.sh
Created March 27, 2019 15:36
Sync all of my GitHub repos to a backup server every night
#!/bin/bash
# You need a GitHub token with repo access for your account. You can create one here...
# https://github.com/settings/tokens
GITHUB_TOKEN=abc123
cd ~
mkdir github
cd github
@tylerhall
tylerhall / count.php
Created April 15, 2014 21:43
A quick PHP script to count the total number of words written in your Day One journal file.
<?PHP
$journal_fn = $argv[1];
$entries_dir = $journal_fn . '/entries/';
$entries = scandir($entries_dir);
print_r($entries);
$total_words = 0;
@tylerhall
tylerhall / keybase.md
Created March 26, 2014 20:10
keybase.md

Keybase proof

I hereby claim:

  • I am tylerhall on github.
  • I am tylerhall (https://keybase.io/tylerhall) on keybase.
  • I have a public key whose fingerprint is 6A6A CE7D E268 8F9A 9E97 E2B6 14C1 60A4 6D68 61A9

To claim this, I am signing this object:

@tylerhall
tylerhall / jekyll-import.php
Created March 21, 2014 00:02
Import a Jekyll posts directory into WordPress
<?PHP
require '/path/to/markdown-extra.php';
$db = mysql_connect('localhost', 'root', 'password') or die(mysql_error());
mysql_select_db('tylerio', $db) or die(mysql_error());
$files = scandir('posts');
array_shift($files); // .
array_shift($files); // ..
@tylerhall
tylerhall / gist:5687932
Created May 31, 2013 20:57
Now that I've reached 90% of my monthly data usage, this is the "css" that Comcast is serving in place of http://cdn.sstatic.net/stackoverflow/all.css?v=c9b143e6d693 Notice, they're trying to "warn me" about my data usage, but clearly their MiM proxy that's rewriting my web requests is broken.
<html>
<head>
<style type="text/css">
/* Basic Markup Styles */
* { margin: 0; padding: 0; }
img { border: none; }
body {
font: 68.75% Arial, Tahoma, Helvetica, sans-serif;
@tylerhall
tylerhall / index.php
Created April 21, 2013 20:51
Modified WordPress index.php to work with any domain name.
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells WordPress to load the WordPress theme and output it.