Skip to content

Instantly share code, notes, and snippets.

View tylerhall's full-sized avatar

Tyler Hall tylerhall

View GitHub Profile
@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' [email protected]:/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
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 / OutlineViewController+Extension.m
Created April 24, 2019 20:44
NSOutlineView Drag and Drop with Core Data
- (void)outlineViewItemDidCollapse:(NSNotification *)notification {
VirtualHost *vh = [[[notification userInfo] valueForKey:@"NSObject"] representedObject];
vh.isExpandedValue = NO;
}
- (void)outlineViewItemDidExpand:(NSNotification *)notification {
VirtualHost *vh = [[[notification userInfo] valueForKey:@"NSObject"] representedObject];
vh.isExpandedValue = YES;
}
</code></pre>
<?php
if(isset($_SERVER['HTTP_X_ORIGINAL_HOST'])) {
$proto = empty($_SERVER['HTTP_X_FORWARDED_PROTO']) ? 'http' : (($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ? 'https' : 'http');
$url = $proto . '://' . $_SERVER['HTTP_X_ORIGINAL_HOST'];
if($proto == 'https') { $_SERVER['HTTPS'] = 'on'; }
} else {
$s = empty($_SERVER['HTTPS']) ? '' : ($_SERVER['HTTPS'] == 'on') ? 's' : '';
$port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (":".$_SERVER['SERVER_PORT']);
$url = "http$s://" . $_SERVER['HTTP_HOST'] . $port;
}
tell application "VirtualHostX"
set devSite to make new website
set devSite's name to "dev-website"
set devSite's local path to "/Users/thall/Sites/tylerio"
apply changes
set urlToOpen to local url of devSite
tell application "Safari"
@tylerhall
tylerhall / killSSHTunnel.sh
Created January 7, 2020 22:17
Find the appropriate SSH tunnel's pid and kill the process
#!/bin/bash
kill -9 `ps -ax | grep imacvpn | head -n1 | cut -f1 -d " "`
var leftExpressions = [
NSExpression(forKeyPath: "pageTitle"),
NSExpression(forKeyPath: "pageDescription"),
NSExpression(forKeyPath: "content"),
NSExpression(forKeyPath: "url")
]
var operatorTypes = [
NSNumber(value: NSComparisonPredicate.Operator.equalTo.rawValue),
NSNumber(value: NSComparisonPredicate.Operator.contains.rawValue),
NSNumber(value: NSComparisonPredicate.Operator.beginsWith.rawValue),
> Ears --help
USAGE: ears [--input <input>] [--output <output>] [--list-outputs] [--list-inputs]
OPTIONS:
-i, --input <input> The audio input device to make current.
The name must be an exact match.
-o, --output <output> The audio output device to make current.
The name must be an exact match.
--list-outputs Show available output devices.
--list-inputs Show available input devices.
tell application "Ears"
set audio input "Soundcore Life Q20"
set audio output "iMac Pro Speakers"
end tell
@tylerhall
tylerhall / config
Created August 26, 2020 15:27
Fix Catalina SSH Bug
# Solves https://tyler.io/so-uh-i-think-catalina-10154-broke-ssh/
If you add a timeout to your SSH command, it will work.
ssh -p 6789 -oConnectTimeout=10 domain.com
Or, you can automatically apply it to all SSH connections by adding
Host *
ConnectTimeout 10