Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
TASK_NAMES = {'unit' => 'units',
'functional' => 'functionals',
'integration' => 'integration'}
tasks = {'unit' => [],
'functional' => [],
'integration' => []}
requested = ARGV.clone
@brokensandals
brokensandals / gist:1379908
Created November 20, 2011 06:49
clojure detect and linkify URLs
; 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
@brokensandals
brokensandals / backup-evernote-html.sh
Last active March 24, 2019 14:21
script & launchd config for backing up Evernote to git repo
#!/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 / mac-photos-export-reorganize.rb
Created October 8, 2019 17:25
Script to update folder names of Mac Photos app exports, so that the date comes first.
#!/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 July 28, 2019 23:32
A python solution to HackerRank's "Common Child" problem
#!/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 November 6, 2022 09:33
Google Docs/Sheets/Slides automated backups script
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 September 19, 2017 03:22
script & launchd config for importing photos from a folder into the Photos app on Mac
<?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>