From 355d4996dc32988aabe000fbfaa1a9bbdd9ec585 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 26 Mar 2023 13:49:36 +0200 Subject: Add initial scripts --- think | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 think (limited to 'think') diff --git a/think b/think new file mode 100755 index 0000000..63e258a --- /dev/null +++ b/think @@ -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}" -- cgit v1.2.3