-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjournal.rb
executable file
·73 lines (60 loc) · 2.2 KB
/
journal.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env ruby
require 'date'
filepath = "#{ENV['HOME']}/Notes/"
today = Date.today
filename = today.strftime('%Y-%m-%d.md')
last_year = today.prev_year.strftime('%Y-%m-%d')
this_week = today.strftime('%G-W%V')
this_week_monday = today - (today.cwday-1)
week_filename = this_week + '.md'
weather_raw = `curl -s https://weather.gc.ca/rss/city/ab-50_e.xml`
today_weather_raw = weather_raw.split('<entry>').slice(3..4).join
today_weather_list = today_weather_raw.scan(/.*<title>(.*)<\/title>/).flatten
journal_template = <<~JOURNAL
# #{today.strftime('%A, %b %d, %Y')}
[[#{last_year}]] | [[#{this_week}]]
## Weather
#{today_weather_list[0]}
#{today_weather_list[1]}
## TODO
- [ ] 🗓 Check calendar for scheduled events
-
## Daily Notes
-
JOURNAL
File.open("#{filepath}#{filename}", 'a') { |f| f.write "#{journal_template}" }
puts "Wrote daily template to #{filepath}#{filename}"
weekly_template = <<~WEEKLY
# #{this_week}
## Big Three
1.
2.
3.
## Daily stuff
- Monday, [[#{this_week_monday.strftime('%Y-%m-%d')}]]
- Tuesday, [[#{this_week_monday.next_day.strftime('%Y-%m-%d')}]]
- Wednesday, [[#{this_week_monday.next_day(2).strftime('%Y-%m-%d')}]]
- Thursday, [[#{this_week_monday.next_day(3).strftime('%Y-%m-%d')}]]
- Friday, [[#{this_week_monday.next_day(4).strftime('%Y-%m-%d')}]]
- Saturday, [[#{this_week_monday.next_day(5).strftime('%Y-%m-%d')}]]
- Sunday, [[#{this_week_monday.next_day(6).strftime('%Y-%m-%d')}]]
## Last week [[#{(today-7).strftime('%G-W%V')}]]
- Tasks:
- [ ] Add meetings from last week to contacts and events
- [ ] Make sure all [[TODO]] items from last week were either closed or moved
- [ ] Make sure there are no recurring items that somehow got marked as [[DONE]]
- Biggest wins:
-
- How far did you get on last week's big 3?
1.
2.
3.
- What worked? What didn't?
-
- What will you keep, improve, start, or stop based on the above?
-
WEEKLY
unless File.exist?("#{filepath}#{week_filename}")
File.open("#{filepath}#{week_filename}", 'w') { |f| f.write "#{weekly_template}" }
puts "Wrote weekly template to #{filepath}#{week_filename}"
end