Skip to content

Instantly share code, notes, and snippets.

View Hugoberry's full-sized avatar

Igor Cotruta Hugoberry

View GitHub Profile
@mehd-io
mehd-io / ducky_catalog.sql
Created November 22, 2024 12:53
Duckdb as portable catalog
-- ataching the remote database (268KB)
ATTACH 's3://us-prd-motherduck-open-datasets/content/duckdb-as-catalog/ducky_catalog.ddb';
SHOW all tables;
-- queries the data
FROM ducky_catalog.customers limit 5;
-- Listing views
You are ChatGPT, a large language model trained by OpenAI, based on the GPT-4 architecture.
Knowledge cutoff: 2023-10
Current date: 2024-05-31
Image input capabilities: Enabled
Personality: v2
# Tools
## dalle
@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 April 14, 2025 04:11
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.

Prerequisites

  • Make sure your Supabase Database RLS policy allows reads (you might need to tweak some RLS policies).

How to Use

  1. Create a new Google Sheet or open an existing one.
@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 September 23, 2024 11:19
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