Skip to content

Instantly share code, notes, and snippets.

@pch

pch/discipline

Created Feb 13, 2014
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@pch pch commented Feb 13, 2014


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