Skip to content

Instantly share code, notes, and snippets.

@craigeley
craigeley / toggl_reporter.rb
Last active April 6, 2018 02:39
When used with Hazel, a script that parses data from the Reporter app and starts a new time entry in Toggl.
#!/usr/bin/ruby
# Scipt for Using Reporter to start time entries in Toggl
require 'time'
require 'json'
# Prevent encoding errors on OSX
if RUBY_VERSION =~ /2.*.*/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
@craigeley
craigeley / foursquare_reporter.rb
Last active July 27, 2017 23:27
This gist checks you into your most recent Foursquare location from the Reporter iOS app, if you aren't already checked in there. To read more, see http://verifyandrepair.com/02-26-2016/using-reporter-foursquare/
#!/usr/bin/env ruby
# Use Reporter as a Foursquare Client
# Assumes your Reports contain these two questions:
# "What are you doing?" and
# "Where are you?"
require 'time'
require 'json'
require 'net/http'
@craigeley
craigeley / reporter_to_airtable.rb
Last active March 16, 2017 09:55
An example of moving Reporter entries to Airtable in near-real time using Reporter's JSON output and the Airtable API.
#!/usr/bin/env ruby
# Scipt Example for Moving Reporter Entries to Airtable Rows in near-real time
require 'time'
require 'json'
# To prevent encoding errors on OSX
if RUBY_VERSION =~ /2.*.*/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
@craigeley
craigeley / doing_timer.sh
Created December 2, 2015 02:15
A script that shows elapsed time of the current `doing` task in TextBar. Change the path to your doing in line 5.
if [[ `/usr/local/bin/doing last` == *"@done"* ]]; then
echo "💬";
else
name=`/usr/local/bin/doing last | sed 's/@.*//g'`;
start=`grep -o -m 1 "\d*-\d*-\d*\s\d*:\d*\s" /path/to/what_was_i_doing.md`;
date1=`date -j -f '%Y-%m-%d %H:%M ' "$start" +"%s"`;
now=`date -j +"%s"`;
diff=$(($now-$date1));
echo "$name 🕗$(printf "%02d" $(($diff / 3600))):$(printf "%02d" $((($diff / 60) % 60)))"
fi
@craigeley
craigeley / markdown_to_day_one.rb
Last active April 6, 2018 02:39
An Automator action to send edited sidecar Markdown files back to Day One.
if RUBY_VERSION =~ /2.*.*/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
dayone_path = '/path/to/journal.dayone/entries/'
file_path = ARGV[0]
/UUID:\s(?<uuid>.*)/ =~ IO.readlines(file_path)[1]
# Create working plist file
@craigeley
craigeley / day one_to_markdown.rb
Last active April 6, 2018 02:34
When run with Hazel, this script takes a Day One file and creates a sidecar Markdown file and an alias to that file. When the Day One entry is modified, so is the Markdown file, even if it is moved and/or renamed.
#!/usr/local/bin/ruby
require 'plist'
# Fix encoding errors
if RUBY_VERSION =~ /2.2/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end

Keybase proof

I hereby claim:

  • I am craigeley on github.
  • I am craigeley (https://keybase.io/craigeley) on keybase.
  • I have a public key whose fingerprint is CC2E 4AE9 28DA E157 B92B 8836 A6B7 72EA 445E 9C04

To claim this, I am signing this object:

@craigeley
craigeley / github_issues_to_reminders.rb
Last active April 1, 2017 20:24
If you have a server with [rem](https://github.com/kykim/rem) installed, this Ruby script can create and complete Apple Reminders when GitHub issues are opened or closed. It is currently configured to push issues from a single repo to multiple iCloud lists based on issue tags. These lists must already exist.
require 'sinatra'
require 'json'
require 'time'
require 'octokit'
require 'yaml'
set :bind, '0.0.0.0'
# Fix Encoding Errors on OSX
if RUBY_VERSION =~ /2.*.*/
#!/usr/bin/env ruby
# Based on everwatch.rb by Brett Terpstra, 2011, a 2013 update by spetschu, and a 2014 update by regedor
# Write in Markdown in Evernote and Backup your Markdown files in Dropbox
# Uncomment the following lines if you are having encoding problems in OS X
# if RUBY_VERSION =~ /2.0.0/
# Encoding.default_external = Encoding::UTF_8
# Encoding.default_internal = Encoding::UTF_8
# end
#!/usr/bin/env ruby
# Based on everwatch.rb by Brett Terpstra, 2011, a 2013 update by spetschu, and a 2014 update by regedor
# Write in Markdown in Evernote and Backup Markdown files in Dropbox
# Change the next two lines with your account number and the path to your backup folder
watch_folder = File.expand_path("/Users/USERNAME/Library/Containers/com.evernote.Evernote/Data/Library/Application Support/com.evernote.Evernote/accounts/www.evernote.com/YOUR-ACCOUNT-NUMBER/content/")
mark_folder = "~/Dropbox/Evernotes/"
counter = 0