m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/think.rb
diff options
context:
space:
mode:
authorMarcin Chrzanowski <m@m-chrzan.xyz>2021-07-24 01:01:19 +0200
committerMarcin Chrzanowski <m@m-chrzan.xyz>2021-07-24 01:01:19 +0200
commitd11f14949125a5595f70df7bdce973ba68e5ab76 (patch)
tree588b572506cb40671bcce16b4280882f91ce3d78 /think.rb
parent2db1caf455e3b327e0fe8aba3d24f14ed2f4ffde (diff)
Add the think script
Diffstat (limited to 'think.rb')
-rwxr-xr-xthink.rb24
1 files changed, 24 insertions, 0 deletions
diff --git a/think.rb b/think.rb
new file mode 100755
index 0000000..63e258a
--- /dev/null
+++ b/think.rb
@@ -0,0 +1,24 @@
+#!/bin/env ruby
+
+require "date"
+
+THOUGHTS_DIR = "vultr:/srv/thoughts"
+
+today = Date::today
+
+# .wday returns 0 for Sunday.
+# If today is Sunday, we want to put today's thoughts in next Sunday's file so
+# today's Sunday Corner doesn't change mid-day.
+days_till_next_sunday = 7 - today.wday
+
+next_sunday = today + days_till_next_sunday
+
+remote_file = "#{THOUGHTS_DIR}/#{next_sunday}"
+local_file = "/tmp/sunday-thoughts-#{next_sunday}"
+
+system "touch #{local_file}"
+system "scp #{remote_file} #{local_file}"
+system "$VISUAL #{local_file}"
+# Note that if this scp fails and you rerun the script, the first scp above (if
+# it succeeds) will overwrite your current local file.
+system "scp #{local_file} #{remote_file}"