Skip to content

Instantly share code, notes, and snippets.

View cbaragao's full-sized avatar

Chris Aragao cbaragao

View GitHub Profile
@cbaragao
cbaragao / Prompter.ontm
Created May 15, 2026 00:39
A prompt form for OneNote using OneTastic
function Main($arg, $context)
$prompter = DialogBox_Create("")
DialogBox_AddLabel($prompter, "1 - Objective")
DialogBox_AddLabel($prompter, " ")
DialogBox_AddTextBox($prompter, "&Task", "Task", "", false)
DialogBox_AddDropDown($prompter, "&Output format", "OutputFormat", "Prose", Array("Prose", "Bullet list", "Numbered list", "Table", "JSON", "Code", "Step-by-step"))
DialogBox_AddDropDown($prompter, "&Length target", "LengthTarget", "Concise", Array("Very short", "Concise", "Medium", "Long"))
// Function to calculate the distance between two geographic coordinates
GetDistance(lat1:Number, lon1:Number, lat2:Number, lon2:Number):Number = With(
{
// Convert latitude and longitude differences from degrees to radians
dLat: (lat2 - lat1) * Pi() / 180.0,
dLon: (lon2 - lon1) * Pi() / 180.0,
// Convert original latitudes to radians
(l as list, selections as list)=>
let
Source =
List.Accumulate(
selections,
{},
(state,current)=>
if
Text.Contains(current,":")
then
(l as list, range as list)=>
let
Start_Position = List.PositionOf(l, range{0}),
End_Position = List.PositionOf(l, range{1}),
Result= List.Range(l,Start_Position,(End_Position-Start_Position)+1)
in
Result
//SPEC
{
"data": {
"name": "dataset"
},
"title": "Sales Variance by Product",
"transform": [
{
"calculate": "17000000",
"as": "target"
//SPEC
{
"data": {
"name": "dataset"
},
"title": "Sales Variance by Product",
"transform": [
{
//"calculate": "datum['Total Sales'] *.80","as": "target"
"calculate": "17000000",
//SPEC
{
"data": {
"name": "dataset"
},
"title": "Sales Variance by Product",
"transform": [
{
//"calculate": "datum['Total Sales'] *.80","as": "target"
"calculate": "17000000",
{
"data": {
"name": "dataset"
},
"title":"Total Sales by Segment - Vertical Bar Chart",
"encoding": {
"x": {
"field": "Segment",
"type": "nominal",
"sort":"-y",
// SPECS
{
"data": {
"name": "dataset"
},
"title":"Sales Variance by Product",
"transform": [
{
//"calculate": "datum['Total Sales'] *.80","as": "target"
(t as table, seed as number) =>
let
// Step 1: Add an index column to the input table to preserve row order and enable alignment
Source = Table.AddIndexColumn(t, "__Index", 0, 1, Int64.Type),
// Step 2: Generate a reproducible list of random numbers using the provided seed
// This ensures consistent output across refreshes or deployments
Random_List = List.Random(Table.RowCount(t), seed),
// Step 3: Convert the random list into a table and add an index column for joining