Skip to content

Instantly share code, notes, and snippets.

View typeoneerror's full-sized avatar
🤠
iOS, Capacitor, Ember, Vue, Rails

Benjamin Borowski typeoneerror

🤠
iOS, Capacitor, Ember, Vue, Rails
View GitHub Profile
@typeoneerror
typeoneerror / day-of-week.js
Last active July 19, 2024 20:53
Formatted Day of Week (Notion Formula)
lets(
/* number of day of week, 0-6 (starting with sunday as 0) */
no, prop("Date").formatDate("d").toNumber(),
/* day name */
day, prop("Date").formatDate("dddd"),
/* save the colors we want for each day */
color, ifs(
no == 1, "blue", /* mon */
@typeoneerror
typeoneerror / is_valid.js
Created February 6, 2024 03:43
Is Valid?
prop("Name").test("Journal: \w{3} \d{1,2}, \d{4}")
lets(
/* Find all unfinished tasks */
tasks, prop("Tasks").filter(current.prop("Status") != "Done"),
/* Find all the people assigned to those tasks */
people,
tasks
.map(current.prop("Assignee"))
/**
* Because Assignee is a Person property, it's a list,
@typeoneerror
typeoneerror / next-action-notion.js
Created September 20, 2023 16:09
Next Action in a Project
lets(
/* Store unfinished actions */
actions, prop("Actions").filter(!["Done", "Archive"].includes(current.prop("Status"))),
/* Sort by timestamp of task and store with id */
actionId,
actions
.map(formatDate(current.prop("Date"), "X") + "-" + current.id())
.sort()
.first()
@typeoneerror
typeoneerror / monthly-median.js
Created September 15, 2023 21:38
Calculating median score through two databases
lets(
values, prop("Agenda(s)").map(current.prop("Journal Entries").map(current.prop("Readiness"))).flat().sort(),
mid, (values.length() / 2).floor(),
value, values.length() % 2 == 0 ? (values.at(mid) + values.at(mid - 1)) / 2 : values.at(mid),
value
)
@typeoneerror
typeoneerror / average.js
Last active August 6, 2024 00:22
Pseudo Notion rollup calculations as Formulas 2.0
lets(
values, prop("Values").map(current.prop("Value")).filter(!current.empty() || current == 0),
values.sum() / values.length()
)
@typeoneerror
typeoneerror / days-left.js
Last active September 16, 2023 15:48
Days left in Notion
lets(
nowVal, now(),
/* We need now as just a date with no time */
nowDate, nowVal.formatDate("YYYY-MM-DD").parseDate(),
dueDate, prop("Due Date").formatDate("YYYY-MM-DD").parseDate(),
/* Days between now and the due date */
days, dateBetween(dueDate, nowDate, "days"),
@typeoneerror
typeoneerror / next-action.js
Created September 14, 2023 19:48
Display next incomplete task in Notion
lets(
/* Store unfinished actions */
actions, prop("Actions").filter(current.prop("Status") != "Done"),
/* Sort by timestamp of task and store with id */
actionId,
actions
.map(formatDate(current.prop("Date"), "X") + "-" + current.id())
.sort()
.first()
lets(
/* Store unfinished tasks */
tasks, prop("Tasks").filter(current.prop("Status") != "Done"),
/* Sort by timestamp of task and store with id */
task,
tasks
.map(formatDate(current.prop("Date"), "X") + "-" + current.id())
.sort()
.first(),
@typeoneerror
typeoneerror / relation-by-value.js
Last active August 6, 2024 00:26
Sort a Notion relation by value with highlights
prop("Videos")
.map(current.prop("Views"))
.sort()
.reverse()
.map(
lets(
views,
current,
prop("Videos").find(current.prop("Views") == views)
)