Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 12d3244

Browse filesBrowse files
committed
taxonomy fix
1 parent f8572f7 commit 12d3244
Copy full SHA for 12d3244

File tree

Expand file treeCollapse file tree

21 files changed

+666
-9
lines changed
Filter options
Expand file treeCollapse file tree

21 files changed

+666
-9
lines changed

‎content/posts/fitness-track.md

Copy file name to clipboardExpand all lines: content/posts/fitness-track.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
+++
22
title = 'Fitness Track'
33
date = 2023-09-29T20:48:38+05:30
4-
tags: [fitness]
4+
tags = [ "fitness" ]
55
draft = false
66
+++
77

‎public/categories/index.html

Copy file name to clipboardExpand all lines: public/categories/index.html
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ <h2 class="side-title">
5858

5959
<ul>
6060

61+
<li>
62+
<a href="/posts/fitness-track/">Fitness Track</a>
63+
</li>
64+
6165
<li>
6266
<a href="/posts/my-first-post/">My First Post</a>
6367
</li>
@@ -81,6 +85,10 @@ <h2>Tags</h2>
8185

8286
<ul>
8387

88+
<li>
89+
<a href="/tags/fitness">fitness (1)</a>
90+
</li>
91+
8492
</ul>
8593
</div>
8694

‎public/index.html

Copy file name to clipboardExpand all lines: public/index.html
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,35 @@
4949

5050

5151

52+
<section class="list-item">
53+
<h1 class="title"><a href="/posts/fitness-track/">Fitness Track</a></h1>
54+
55+
<div class="tips">
56+
<div class="date">
57+
<time datetime="2023-09-29 20:48:38 &#43;0530 IST">2023/09/29</time>
58+
</div>
59+
60+
61+
62+
63+
<div class="tags">
64+
<span>Tags:</span>
65+
66+
<a href="/tags/fitness">fitness</a>
67+
68+
</div>
69+
70+
</div>
71+
72+
<div class="summary">
73+
74+
Fitness Tracking 🔗The post will describe how I track my fitness journey so far.
75+
Slight background: I am on the journey to be the person who goes to gym daily, my goal is to reduce weight, and get lean. I go to cult for gym.
76+
What all I track so far? 🔗 Weight (morning and night) Number of weeks I had been regular in gym/number of classes attended. Occasional BMI and other metrics from InBody machine installed in the gym I go to.
77+
78+
</div>
79+
</section>
80+
5281
<section class="list-item">
5382
<h1 class="title"><a href="/posts/my-first-post/">My First Post</a></h1>
5483

@@ -107,6 +136,10 @@ <h2 class="side-title">
107136

108137
<ul>
109138

139+
<li>
140+
<a href="/posts/fitness-track/">Fitness Track</a>
141+
</li>
142+
110143
<li>
111144
<a href="/posts/my-first-post/">My First Post</a>
112145
</li>
@@ -130,6 +163,10 @@ <h2>Tags</h2>
130163

131164
<ul>
132165

166+
<li>
167+
<a href="/tags/fitness">fitness (1)</a>
168+
</li>
169+
133170
</ul>
134171
</div>
135172

‎public/index.xml

Copy file name to clipboardExpand all lines: public/index.xml
+41-1Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,47 @@
66
<description>Recent content on My Personal Blog</description>
77
<generator>Hugo -- gohugo.io</generator>
88
<language>en-us</language>
9-
<lastBuildDate>Fri, 29 Sep 2023 20:26:28 +0530</lastBuildDate><atom:link href="https://singhcoder.github.io/index.xml" rel="self" type="application/rss+xml" />
9+
<lastBuildDate>Fri, 29 Sep 2023 20:48:38 +0530</lastBuildDate><atom:link href="https://singhcoder.github.io/index.xml" rel="self" type="application/rss+xml" />
10+
<item>
11+
<title>Fitness Track</title>
12+
<link>https://singhcoder.github.io/posts/fitness-track/</link>
13+
<pubDate>Fri, 29 Sep 2023 20:48:38 +0530</pubDate>
14+
15+
<guid>https://singhcoder.github.io/posts/fitness-track/</guid>
16+
<description>&lt;h1 id=&#34;fitness-tracking&#34;&gt;Fitness Tracking &lt;a href=&#34;#fitness-tracking&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h1&gt;&lt;p&gt;The post will describe how I track my fitness journey so far.&lt;/p&gt;
17+
&lt;p&gt;Slight background: I am on the journey to be the person who goes to gym daily, my goal is to reduce weight, and get lean. I go to &lt;a href=&#34;https://www.cult.fit/&#34;&gt;cult&lt;/a&gt; for gym.&lt;/p&gt;
18+
&lt;h2 id=&#34;what-all-i-track-so-far&#34;&gt;What all I track so far? &lt;a href=&#34;#what-all-i-track-so-far&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h2&gt;&lt;ul&gt;
19+
&lt;li&gt;Weight (morning and night)&lt;/li&gt;
20+
&lt;li&gt;Number of weeks I had been regular in gym/number of classes attended.&lt;/li&gt;
21+
&lt;li&gt;Occasional BMI and other metrics from &lt;a href=&#34;https://www.inbody.in/&#34;&gt;InBody machine&lt;/a&gt; installed in the gym I go to.&lt;/li&gt;
22+
&lt;/ul&gt;
23+
&lt;p&gt;The actual exercises I do, and the number of reps/PRs etc are tracked in the Cult app itself, and for now I had not went into finding the API for that to extract that data into sheet.. Maybe sometime in near future :)&lt;/p&gt;
24+
&lt;h2 id=&#34;how-i-track-all-this&#34;&gt;How I track all this? &lt;a href=&#34;#how-i-track-all-this&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h2&gt;&lt;h3 id=&#34;weight&#34;&gt;Weight &lt;a href=&#34;#weight&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;I have a simple google sheet which looks like this:&lt;/p&gt;
25+
&lt;p&gt;&lt;img src=&#34;image.png&#34; alt=&#34;weight&#34;&gt;&lt;/p&gt;
26+
&lt;p&gt;Column D and E are calculated as &lt;code&gt;Di = Ci - Bi&lt;/code&gt;, &lt;code&gt;Ei = Bi+1 - Ci&lt;/code&gt; tracking how much weight changed in that day, and the next day.&lt;/p&gt;
27+
&lt;p&gt;Until sometime back, this was the interface I used for updating weight everyday: open sheet, add date if not there, add the weight entries. I have a better way which uses this sheet itself as database/backend, gonna come to it at the end.&lt;/p&gt;
28+
&lt;h3 id=&#34;number-of-weeks-i-had-been-regular-in-gymnumber-of-classes-attended&#34;&gt;Number of weeks I had been regular in gym/number of classes attended. &lt;a href=&#34;#number-of-weeks-i-had-been-regular-in-gymnumber-of-classes-attended&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;This data is something I occasionally run a script (I should probably automate this) which calls CULT&amp;rsquo;s API to get the data, and I put that manually into a google sheet then.
29+
Figuring out exact API was done by downloading raw cult apk, pass it through &lt;a href=&#34;https://github.com/shroudedcode/apk-mitm&#34;&gt;apk-mitm&lt;/a&gt; and then use &lt;a href=&#34;https://httptoolkit.com/&#34;&gt;http-toolkit&lt;/a&gt; to intercept the traffic while I visit corresponding page in the app to see the API that the app calls..&lt;/p&gt;
30+
&lt;p&gt;The script looks something like in &lt;a href=&#34;./cult_data_extract.py&#34;&gt;this&lt;/a&gt;.&lt;/p&gt;
31+
&lt;p&gt;The sheet then looks like &lt;img src=&#34;image-1.png&#34; alt=&#34;Cult-Fit-Journey&#34;&gt; with self-explanatory column names.&lt;/p&gt;
32+
&lt;p&gt;Again, this sheet also acts as a backend now, with frontend I will describe at the end on how do I visualize all this.&lt;/p&gt;
33+
&lt;h3 id=&#34;occasional-bmi-and-other-metrics-from-inbody-machine-installed-in-the-gym-i-go-to&#34;&gt;Occasional BMI and other metrics from InBody machine installed in the gym I go to. &lt;a href=&#34;#occasional-bmi-and-other-metrics-from-inbody-machine-installed-in-the-gym-i-go-to&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;This is also backed by google sheet, and I have no automated way to get this data, I just manually enter it into the sheet.&lt;/p&gt;
34+
&lt;p&gt;From the GYM, I get the data printed on a page, from which I manually enter to the frontend I am gonna describe next.&lt;/p&gt;
35+
&lt;p&gt;The sheet by the way looks like:&lt;/p&gt;
36+
&lt;p&gt;&lt;img src=&#34;image-2.png&#34; alt=&#34;InBody&#34;&gt;&lt;/p&gt;
37+
&lt;h2 id=&#34;frontend-for-all-this&#34;&gt;Frontend for all this &lt;a href=&#34;#frontend-for-all-this&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;Entering all this data manually into the google sheet is a hard task, which lead me sometimes missing recording the data. So, I tried to follow the advice that &lt;code&gt;Atomic Habits&lt;/code&gt; book&amp;rsquo;s second rule of habit formation preaches: &lt;code&gt;Make it easy&lt;/code&gt;.&lt;/p&gt;
38+
&lt;p&gt;So, the simplest way I thought was having an app in which I can quickly crunch in numbers (Ik google sheet also is the same thing, but the interface is hard to enter on the phone), so I used &lt;a href=&#34;https://www.appsheet.com/&#34;&gt;appsheet&lt;/a&gt; to quickly create a UI on top of the google sheets.&lt;/p&gt;
39+
&lt;p&gt;My app looks something like this:&lt;/p&gt;
40+
&lt;h3 id=&#34;landing-screen&#34;&gt;Landing screen &lt;a href=&#34;#landing-screen&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;&lt;img src=&#34;image-3.png&#34; alt=&#34;landing screen&#34;&gt;&lt;/p&gt;
41+
&lt;p&gt;This shows the weight entries, and a &lt;code&gt;+&lt;/code&gt; button to add in new entries, and clicking on anyone brings interface like this: &lt;img src=&#34;image-4.png&#34; alt=&#34;edit-mode&#34;&gt;, where I can edit during night to record night weight.&lt;/p&gt;
42+
&lt;h3 id=&#34;inbody-results&#34;&gt;InBody Results &lt;a href=&#34;#inbody-results&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;Exactly similar to Landing screen, but another tab at the bottom for this.&lt;/p&gt;
43+
&lt;h3 id=&#34;charts---weight-and-classes&#34;&gt;Charts - Weight and Classes &lt;a href=&#34;#charts---weight-and-classes&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The third tab has charts for how weight is progressing and for cult gym classes.&lt;/p&gt;
44+
&lt;p&gt;&lt;img src=&#34;image-5.png&#34; alt=&#34;weight chart&#34;&gt;&lt;/p&gt;
45+
&lt;p&gt;&lt;img src=&#34;image-6.png&#34; alt=&#34;gym-classes&#34;&gt;&lt;/p&gt;
46+
&lt;h3 id=&#34;inbody-charts&#34;&gt;InBody charts &lt;a href=&#34;#inbody-charts&#34; class=&#34;anchor&#34;&gt;🔗&lt;/a&gt;&lt;/h3&gt;&lt;p&gt;The last one has inbody charts for metrics: Body Fat Percentage, Total Fat (kg), Muscle Mass (kg), Visceral Fat Level, Waist Hip Ratio.&lt;/p&gt;
47+
</description>
48+
</item>
49+
1050
<item>
1151
<title>My First Post</title>
1252
<link>https://singhcoder.github.io/posts/my-first-post/</link>

‎public/posts/cult_data_extract.py

Copy file name to clipboard
+74Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import csv
2+
import json
3+
from datetime import datetime, timedelta
4+
5+
import requests
6+
7+
# Replace <SECRET> with your actual secret token
8+
headers = {
9+
"accept": "application/json",
10+
"cookie": "", # get from the cult website, any curl call, get the value of header `Cookie`...
11+
"clientversion": "10.08",
12+
"connection": "Keep-Alive",
13+
"content-type": "application/json; charset=utf-8"
14+
}
15+
16+
start_date_str = "2022-04-25"
17+
end_date_str = "2023-08-04"
18+
current_date = datetime.strptime(start_date_str, "%Y-%m-%d")
19+
20+
csv_filename = f"fitness_report.csv"
21+
with open(csv_filename, "w", newline="") as csvfile:
22+
csv_writer = csv.writer(csvfile, delimiter="\t")
23+
csv_writer.writerow(["StartDate", "EndDate", "ClassesAttended", "CaloriesBurnt", "ExercisesDone", "FocusedOn", "NotFocusedOn", "Summary"])
24+
while current_date <= datetime.strptime(end_date_str, "%Y-%m-%d"):
25+
current_date_str = current_date.strftime("%Y-%m-%d")
26+
this_week_end_date = current_date + timedelta(days=6)
27+
this_week_end_date_str = this_week_end_date.strftime("%Y-%m-%d")
28+
29+
url = f"https://www.cult.fit/api/cult/fitnessReport?reportType=WEEKLY&startDate={current_date_str}"
30+
response = requests.get(url, headers=headers)
31+
data = response.json()
32+
33+
try:
34+
widgets = data["widgets"]
35+
classMissedWidgets = [w for w in widgets if w["widgetType"] == "CLASS_MISSED_WIDGET"]
36+
classMissedWidget = classMissedWidgets[0] if len(classMissedWidgets) > 0 else None
37+
if classMissedWidget:
38+
csv_writer.writerow([current_date_str, this_week_end_date_str, 0, 0, "", "", "", classMissedWidget["title"]["value"]])
39+
print(f"Processed week {current_date_str} to {this_week_end_date_str}")
40+
current_date += timedelta(days=7)
41+
continue
42+
fitnessReportSummary = [w for w in widgets if w["widgetType"] == "FITNESS_REPORT_SUMMARY_CARD_WIDGET"][0]
43+
metricWidget = [w for w in widgets if w["widgetType"] == "REPORT_METRIC_DETAIL_WIDGET"][0]
44+
tagViewWidgets = [w for w in widgets if w["widgetType"] == "TAG_VIEW_WIDGET"]
45+
exercisesDoneWidgets = [w for w in tagViewWidgets if "header" not in w]
46+
exercisesDoneWidget = exercisesDoneWidgets[0] if len(exercisesDoneWidgets) > 0 else None
47+
youFocusedOnWidgets = [w for w in tagViewWidgets if "header" in w and w["header"] == "YOU FOCUSSED ON"]
48+
youFocusedOnWidget = youFocusedOnWidgets[0] if len(youFocusedOnWidgets) > 0 else None
49+
start_date = fitnessReportSummary["startDate"]
50+
end_date = fitnessReportSummary["endDate"]
51+
classes_attended = metricWidget["metricSection"]["metricDisplayValue"]
52+
calories_burnt = fitnessReportSummary["caloriesBurnt"]
53+
54+
exercises_done = ""
55+
if exercisesDoneWidget:
56+
exercises_done = "\n".join(tag["title"] + "(" + tag["value"] + ")" for tag in exercisesDoneWidget["tags"] if not tag["disabled"])
57+
focused_on = ""
58+
not_focused_on = ""
59+
summary = ""
60+
if youFocusedOnWidget:
61+
focused_on = "\n".join([tag["title"] for tag in youFocusedOnWidget["tags"] if not tag["disabled"]])
62+
not_focused_on = "\n".join([tag["title"] for tag in youFocusedOnWidget["tags"] if tag["disabled"]])
63+
summary = youFocusedOnWidget["footer"]["dataText"]
64+
csv_writer.writerow([start_date, end_date, classes_attended, calories_burnt, exercises_done, focused_on, not_focused_on, summary])
65+
print(f"Processed week {start_date} to {end_date}")
66+
# Move to the next week
67+
current_date += timedelta(days=7)
68+
except Exception as e:
69+
print(f"Error processing week {current_date_str} to {this_week_end_date_str}")
70+
print(f"data json = {json.dumps(data, indent=4)}")
71+
raise e
72+
73+
74+
print(f"CSV file '{csv_filename}' created successfully.")

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.