Skip to content

Instantly share code, notes, and snippets.

View Hugoberry's full-sized avatar

Igor Cotruta Hugoberry

View GitHub Profile
@DOsinga
DOsinga / Errors.gs
Created February 16, 2024 22:54
Implements throw_error_(msg, line) that will show in Apps script an error at the specified line by implementing 10k functions
function err_1_(message) { throw new Error(message); }
function err_2_(message) { throw new Error(message); }
function err_3_(message) { throw new Error(message); }
function err_4_(message) { throw new Error(message); }
function err_5_(message) { throw new Error(message); }
function err_6_(message) { throw new Error(message); }
function err_7_(message) { throw new Error(message); }
function err_8_(message) { throw new Error(message); }
function err_9_(message) { throw new Error(message); }
function err_10_(message) { throw new Error(message); }
@ttomasz
ttomasz / google_sheets_example.py
Created May 24, 2023 19:16
Query Google Spreadsheet directly using Duckdb and Fabduckdb extension
import duckdb
import fabduckdb
import gspread
import pandas as pd
def read_gsheet(service_account_json_path: str, gsheets_url: str, worksheet_name: str) -> pd.DataFrame:
gc = gspread.service_account(filename=service_account_json_path, scopes=gspread.auth.READONLY_SCOPES)
gsheet = gc.open_by_url(gsheets_url)
data = gsheet.worksheet(worksheet_name).get_all_records()
@braden-w
braden-w / description.md
Last active July 1, 2024 16:41
Google Sheets Script for Fetching Data from Supabase

Google Sheets Script for Fetching Data from Supabase

This Google Sheets script fetches data from a Supabase database and writes the selected headers and data to the active sheet. The script first clears the sheet, writes the headers, then fetches the data from the Supabase API, and finally writes the data to the sheet. It is optimized and has anonymized variables for public use.

How to Use

  1. Create a new Google Sheet or open an existing one.
  2. Click on "Extensions" in the menu, then select "Apps Script." (If you don't see "Extensions," click on "Tools" and then "Script editor.")
  3. In the Apps Script editor, replace the default Code.gs content with the content of supabase_to_google_sheets.gs.
  4. Replace the SUPABASE_URL and SUPABASE_ANON_KEY variables with your actual Supabase URL and anon key.
@dgosbell
dgosbell / AutoPopulateMeasureDescriptionsFromOpenAI.csx
Last active February 17, 2024 03:53
This is a script for tabular editor that will loop through all the measures in a model and get ChatGPT to write a description of the calculation.
#r "System.Net.Http"
using System.Net.Http;
using System.Text;
using Newtonsoft.Json.Linq;
// You need to signin to https://platform.openai.com/ and create an API key for your profile then paste that key
// into the apiKey constant below
const string apiKey = "<YOUR API KEY HERE>";
const string uri = "https://api.openai.com/v1/completions";
const string question = "Explain the following calculation in a few sentences in simple business terms without using DAX function names:\n\n";

Cheat sheet: JavaScript Array methods

Deriving a new Array from an existing Array:

['■','●','▲'].slice(1, 3)           ['●','▲']
['■','●','■'].filter(x => x==='■')  ['■','■']
    ['▲','●'].map(x => x+x)         ['▲▲','●●']
    ['▲','●'].flatMap(x => [x,x])   ['▲','▲','●','●']
// Modified from @mutsuda's https://medium.com/@mutsuda/create-an-ios-widget-showing-google-spreadsheets-data-856767a9447e
// by @levelsio
// HOW TO
// 1) Make a Google Sheet, we'll pull the first cell e.g. A1
// 2) Publish your Google Sheet, File -> Publish To Web
// 3) Copy the SHEET_ID in the URL, put it in here below:
const endpoint = "https://spreadsheets.google.com/feeds/cells/SHEET_ID/1/public/full?alt=json"
// 4) Install Scriptable @ https://apps.apple.com/us/app/scriptable/id1405459188
// 5) Copy this entire script in to Scriptable (tip: you can send it to your iPhone via Whatsapp/Messenger/Telegram etc)
@alexisrolland
alexisrolland / Install Kerberos in Docker
Last active May 28, 2024 10:53
Example of commands to install and use Kerberos in Docker
# Install Kerberos in Linux based Docker image
$ export DEBIAN_FRONTEND=noninteractive
$ apt-get install -y krb5-user libpam-krb5
$ kinit <account>@<COMPANY>.ORG
$ klist
# Create keytab file
$ ktutil
$ addent -password -p <account>@<COMPANY>.ORG -k 1 -e arcfour-hmac
$ write_kt <account>.keytab
@dgosbell
dgosbell / Load-PackageAdomdClient.ps1
Created March 11, 2020 06:15
Load AnalysisServices nuget packages into a Powershell session
#load the type from the Microsoft.AnalysisServices.AdomdClient nuget package
Install-Package Microsoft.AnalysisServices.AdomdClient.retail.amd64 -Source "https://www.nuget.org/api/v2"
$p = get-package Microsoft.AnalysisServices.AdomdClient.retail.amd64
$nugetFile = get-childitem $p.source
$adomdFile = join-path $nugetFile.DirectoryName "lib\net45\Microsoft.AnalysisServices.AdomdClient.dll"
add-type -path $adomdFile
@odzhan
odzhan / rtlcompress.c
Last active June 5, 2021 20:16
Compression using NT Layer DLL API
/**
BSD 3-Clause License
Copyright (c) 2019 Odzhan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
@odzhan
odzhan / winflate.c
Last active March 30, 2024 01:39
Deflate Compression On Windows
/**
BSD 3-Clause License
Copyright (c) 2019 Odzhan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.