Skip to content

Instantly share code, notes, and snippets.

@pch
Created February 13, 2014 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pch/8973757 to your computer and use it in GitHub Desktop.
Save pch/8973757 to your computer and use it in GitHub Desktop.
Tricking myself into writing.
#!/usr/bin/env ruby
#
# I use the following script to trick myself into writing every day.
#
# All it does is create a directory for the current month (YYYY/MM),
# create an empty markdown file for today and annoy the hell out of
# me until I put something in that file.
#
# I run the script with GeekTool every 30 minutes:
# http://projects.tynsoe.org/en/geektool/
#
# The directory structure is:
#
# journal
# 2014
# 01
# 02
# 01.md
# 02.md
# 03.md
# bin
# discipline
#
require 'date'
require 'fileutils'
ROOT_DIR = ::File.expand_path('../../', __FILE__)
date = Date.today
month_dir = ROOT_DIR + '/' + date.strftime('%Y/%m')
filename = month_dir + '/' + date.strftime('%d') + '.md'
unless File.exists?(filename)
FileUtils.mkdir_p(month_dir)
FileUtils.touch(filename)
end
if File.zero?(filename)
`osascript -e 'display notification "You haven’t written anything today! 😢" with title "Write"'`
puts 'Your journal is empty 😢'
end
@pch
Copy link
Author

pch commented Feb 13, 2014


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment