Skip to content

Instantly share code, notes, and snippets.

const json = require("./color.json");
let res = {};
// Parse Grays
let idx = 0;
for (const shade of json.grays) {
let colorLabel = shade.label.split("-")[0];
const colorLevel = idx == 0 ? 50 : 100 * idx
idx++;
@XavierGeerinck
XavierGeerinck / color-to-figma.js
Created March 30, 2022 11:32
color-to-figma.js
const json = require("./color.json");
let res = {};
// Parse Grays
let idx = 0;
for (const shade of json.grays) {
let colorLabel = shade.label.split("-")[0];
const colorLevel = idx == 0 ? 50 : 100 * idx
idx++;
@XavierGeerinck
XavierGeerinck / sql_base64_decoder.md
Last active June 14, 2022 20:51
T-SQL Base64 Decoder

Need to decode a Base64 string?

NOTES:

  • This code isn't strictly required for SQL Server as its native T-SQL based XML processing capabilities can do Base64 transformations. However, Azure Synapse Analytics' Dedicated SQL Pools currently does not have XML capability, but using this function you can have a fast T-SQL solution for decoding Base64 strings.
  • Azure Synapse Analytics' currently does not support table-value constructors. Therefore, to use this code in Synapse the VALUES statements will need to be replaced with SELECT/UNION ALL constructs. Otherwise, the code works AS-IS.

Inspired from the work at:

@XavierGeerinck
XavierGeerinck / winget-install-programs.ps1
Last active August 30, 2022 14:40
WinGet Programs on Clean Install
# 1. Install Winget
# https://www.microsoft.com/en-us/p/app-installer/9nblggh4nns1
# More info: https://github.com/microsoft/winget-cli
# Search Packages: winget search
# 2. Install PC
# Microsoft tools
winget install Microsoft.Edge
winget install Microsoft.WindowsTerminal
winget install Microsoft.PowerToys
// This file was initially generated by Windows Terminal 0.11.1333.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
module.exports = {
// Your queueName (min 3 char, max 65) - will be automatically created in sender.js
queueName: '<queue_name>',
// Go to storage account page --> Storage account name
azureStorageAccount: '<storage_account_name>',
// Go to storage account page --> Access Keys
azureStorageAccessKey: '<storage_access_key>',
};
const azure = require('azure-storage');
const config = require('./config');
const queueService = azure.createQueueService(config.azureStorageAccount, config.azureStorageAccessKey);
console.log(`[Queue - Receiver] Truncating Queue`);
queueService.clearMessages(config.queueName, (error, response) => {
if (error) {
console.log(error);
const azure = require('azure-storage');
const config = require('./config');
const Poller = require('./Poller');
const queueService = azure.createQueueService(config.azureStorageAccount, config.azureStorageAccessKey);
const poller = new Poller(1000);
poller.onPoll(() => {
console.log(`[Queue - Receiver] Polling for messages`);
const azure = require('azure-storage');
const config = require('./config');
const queueService = azure.createQueueService(config.azureStorageAccount, config.azureStorageAccessKey);
queueService.createQueueIfNotExists(config.queueName, (err, result, res) => {
if (err) {
console.error(err);
return;
}
let isWorking = false;
setInterval(() => {
if (isWorking) {
return;
}
isWorking = true;
console.log('do something (example: download URL)');
isWorking = false;