This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const isEnabled = true | |
const numberOfShiftGroups = 2 | |
function onEdit(event) { | |
console.log(`Event range: ${event.range.getA1Notation()}`) | |
if (!isEnabled && event.range.getSheet().getSheetName() !== "Shifts") { | |
return | |
} | |
const speadSheet = SpreadsheetApp.getActiveSpreadsheet() | |
const shiftsSheet = speadSheet.getSheetByName("Shifts") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT usename AS role_name, | |
CASE | |
WHEN usesuper AND usecreatedb THEN | |
CAST('superuser, create database' AS pg_catalog.text) | |
WHEN usesuper THEN | |
CAST('superuser' AS pg_catalog.text) | |
WHEN usecreatedb THEN | |
CAST('create database' AS pg_catalog.text) | |
ELSE | |
CAST('' AS pg_catalog.text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass { | |
public myProp = 13; | |
public static readonly myStaticReadOnlyProp = 99; | |
private myPrivateProp: string | undefined; | |
constructor() { | |
this.myPrivateProp = undefined; | |
} | |
public myPublicFunction() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as r from 'ramda'; | |
import * as fp from 'fp-ts'; | |
type PickStrings<T> = { | |
[Key in keyof T]: string extends T[Key] ? T[Key] : never | |
} | |
type StringKeysAsValues<T> = { | |
[Key in keyof T]-?: string extends T[Key] ? Key : never | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Handling Errors using async/await | |
* Has to be used inside an async function | |
*/ | |
try { | |
const response = await axios.get('https://your.site/api/v1/bla/ble/bli'); | |
// Success 🎉 | |
console.log(response); | |
} catch (error) { | |
// Error 😨 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add field | |
echo '{"hello": "world"}' | jq --arg foo bar '. + {foo: $foo}' | |
# { | |
# "hello": "world", | |
# "foo": "bar" | |
# } | |
# Override field value | |
echo '{"hello": "world"}' | jq --arg foo bar '. + {hello: $foo}' | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates a union type with names of all properties of T where S extends T[Key] | |
* | |
* @example | |
* ```ts | |
* type T = { a: string; b?: string; c: string | undefined; d: string | null; e: number }; | |
* type StringPropertiesFromT = PropertiesOfType<T, string>; // 'a' | 'b' | 'c' | 'd' | |
* ``` | |
*/ | |
export type PropertiesOfType<T, S> = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* | |
NAME: SCRIPT NUGGETS | |
DESCRIPTION: Apps Script functions for use with AppSheet | |
SETUP: Replace YOUR_SHEET_ID in first line with the sheet Id from the sheet URL | |
BY: GreenFlux, LLC | |
*////////////////////////////////////////////////////////////////////////////////////////////////////// | |
const ss = SpreadsheetApp.openById('YOUR_SHEET_ID');//(id from sheetURL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createEventWithAttachment() { | |
var driveFileId = '...'; | |
var file = DriveApp.getFileById(driveFileId); | |
var event = { | |
summary: 'Test Event with Attachments', | |
description: 'Woot!', | |
attachments: [{ | |
fileId: driveFileId, | |
fileUrl: file.getUrl(), | |
mimeType: file.getMimeType(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright 2019 Google LLC. | |
* SPDX-License-Identifier: Apache-2.0 | |
*/ | |
var CHECKBOX_COLUMN = 'B'; | |
function onEdit() { | |
var range = SpreadsheetApp.getActiveRange(); | |
if (range.getA1Notation().split(/\d/)[0] == CHECKBOX_COLUMN && |
NewerOlder