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
View working-on.js
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
View next-action-notion.js
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 / days-left.js
Last active September 16, 2023 15:48
Days left in Notion
View days-left.js
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 / monthly-median.js
Created September 15, 2023 21:38
Calculating median score through two databases
View monthly-median.js
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 September 15, 2023 21:31
Pseudo Notion rollup to calc mean
View average.js
lets(
values, prop("Journal Entries").map(current.prop("Readiness")).filter(!current.empty()),
values.sum() / values.length()
)
@typeoneerror
typeoneerror / next-action.js
Created September 14, 2023 19:48
Display next incomplete task in Notion
View next-action.js
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()
View next-task.js
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 September 7, 2023 18:17
Sort a Notion relation by value with highlights
View relation-by-value.js
prop("Videos")
.map(current.prop("Views"))
.sort()
.reverse()
.map(
lets(
views,
current,
prop("Videos").find(current.prop("Views") == views)
)
@typeoneerror
typeoneerror / confirmation_instructions_tenants.html.erb
Last active March 11, 2023 14:39
Setting up Devise with a custom mailer to send different confirmation emails based on devise scope.
View confirmation_instructions_tenants.html.erb
# doki_core/mailer/confirmation_instructions_tenants.html.erb
I get sent to Tenants when requesting confirmation.
View notion-update-icons.js
const { notion, yargs } = require('../../shared');
const { fetchAllPages, performWithAll } = require('../../shared/fetch-pages');
const databaseId = 'e6a07b67d28a432fbd9029f18f3a27b8';
async function editPage(page) {
const params = {
page_id: page.id,
icon: {
type: 'emoji',