Skip to content

Instantly share code, notes, and snippets.

View Hugoberry's full-sized avatar

Igor Cotruta Hugoberry

View GitHub Profile
@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 March 15, 2024 06:12
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.
Function ConvertTo-DataTable { # https://powersnippets.com/convertto-pson/
[CmdletBinding()]Param( # Version 01.00.01, by iRon
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline = $true)] [PSObject[]]$Object, [HashTable]$ColumnType = @{}
)
$TypeCast = @{
Guid = 'Guid', 'String'
DateTime = 'DateTime', 'String'
DateTimeOffset = 'DateTimeOffset', 'String'
Byte = 'Byte', 'Char', 'Int16', 'Int32', 'Int64', 'UInt16', 'UInt32', 'UInt64', 'Decimal', 'Single', 'Double', 'String', 'Boolean'
SByte = 'SByte', 'Int16', 'Int32', 'Int64', 'Decimal', 'Single', 'Double', 'String', 'Boolean'
Sparkline Column Categorical Axis =
// Static column color - use %23 instead of # for Firefox compatibility
VAR BarColor = "%2301B8AA"
VAR BarOutlineColor = "%23DDDDDD"
VAR BarOutlineWidth = 2
// Obtain number of columns - width generated based on column count (~20 column maximum for bar chart)
VAR BarCount = DISTINCTCOUNT('Table'[Customer Segment])
VAR BarWidth = INT(DIVIDE(100,BarCount))
// Obtain overall min and overall max measure values when evaluated for each column
VAR YMinValue = MINX(VALUES('Table'[Customer Segment]),CALCULATE([Measure Value]))
Sparkline Line =
// Static line color - use %23 instead of # for Firefox compatibility
VAR LineColor = "%2301B8AA"
// "Date" field used in this example along the X axis
VAR XMinDate = MIN('Table'[Date])
VAR XMaxDate = MAX('Table'[Date])
// Obtain overall min and overall max measure values when evaluated for each date