Skip to content

Instantly share code, notes, and snippets.

Jacob Williams brokensandals

View GitHub Profile
@brokensandals
brokensandals / mac-photos-export-reorganize.rb
Created Oct 8, 2019
Script to update folder names of Mac Photos app exports, so that the date comes first.
View mac-photos-export-reorganize.rb
#!/usr/bin/env ruby
# When you export files from the Mac Photos app, it can generate a directory structure like this:
# ./
# ./My Favorite Place - Some City, April 10, 1999
# ./Some Other City, January 1, 1995
#
# This script renames all those directories to follow this structure:
# ./
# ./1995-01-01 Some Other City
@brokensandals
brokensandals / solution.py
Created Jul 28, 2019
A python solution to HackerRank's "Common Child" problem
View solution.py
#!/bin/python3
import os
# Complete the commonChild function below.
def commonChild(s1, s2):
maxAt = {}
for i1 in range(len(s1)):
maxForI1 = 0
@brokensandals
brokensandals / GoogleDocsBackup.gs
Last active Jun 3, 2020
Google Docs/Sheets/Slides automated backups script
View GoogleDocsBackup.gs
var BACKUP_FOLDER_ID = 'INSERT_FOLDER_ID_HERE';
var NATIVE_MIME_TYPES = {};
NATIVE_MIME_TYPES[MimeType.GOOGLE_DOCS] = MimeType.MICROSOFT_WORD;
NATIVE_MIME_TYPES[MimeType.GOOGLE_SHEETS] = MimeType.MICROSOFT_EXCEL;
NATIVE_MIME_TYPES[MimeType.GOOGLE_SLIDES] = MimeType.MICROSOFT_POWERPOINT;
var NATIVE_EXTENSIONS = {};
NATIVE_EXTENSIONS[MimeType.GOOGLE_DOCS] = '.docx';
NATIVE_EXTENSIONS[MimeType.GOOGLE_SHEETS] = '.xlsx';
@brokensandals
brokensandals / net.brokensandals.photos.sync.applefromgoogle.plist
Created Sep 19, 2017
script & launchd config for importing photos from a folder into the Photos app on Mac
View net.brokensandals.photos.sync.applefromgoogle.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>net.brokensandals.photos.sync.applefromgoogle</string>
<key>Program</key>
<string>/Users/jacob/dotfiles/bin/sync-apple-photos-from-google-photos.rb</string>
<key>StartCalendarInterval</key>
<array>
@brokensandals
brokensandals / backup-evernote-html.sh
Last active Mar 24, 2019
script & launchd config for backing up Evernote to git repo
View backup-evernote-html.sh
#!/bin/bash
backup_dir=/Users/jacob/Backup/evernote-html
# thanks to http://veritrope.com/code/get-note-links-in-evernote-for-newly-created-notes/ for how to wait for sync to finish
osascript <<END
with timeout of (30 * 60) seconds
tell application "Evernote"
synchronize
repeat until isSynchronizing is false
@brokensandals
brokensandals / gist:1379908
Created Nov 20, 2011
clojure detect and linkify URLs
View gist:1379908
; From John Gruber's http://daringfireball.net/2010/07/improved_regex_for_matching_urls
; Added a capture group around the protocol so we can distinguish matches that contained it.
(def url-regex #"(?i)\b((?:([a-z][\w-]+:(?:/{1,3}|[a-z0-9%]))|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))")
(defn linkify-urls
"Add A tags around parts of the string that look likely to be URLs."
[text]
(let [matcher (re-matcher url-regex text)]
(if-not (.find matcher)
text ; avoid building a StringBuffer (and presumably copying the string) if there were no matches
View rake-test-individuals.rb
#!/usr/bin/env ruby
TASK_NAMES = {'unit' => 'units',
'functional' => 'functionals',
'integration' => 'integration'}
tasks = {'unit' => [],
'functional' => [],
'integration' => []}
requested = ARGV.clone
You can’t perform that action at this time.