Skip to content

Instantly share code, notes, and snippets.

View lordlycastle's full-sized avatar
🤙
Let it Fly!

lordlycastle

🤙
Let it Fly!
View GitHub Profile
@lordlycastle
lordlycastle / checkAndHide.gs
Created April 12, 2021 20:30 — forked from erickoledadevrel/checkAndHide.gs
Google Apps Script code to hide a row when a checkbox is checked.
/*
* 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 &&
@lordlycastle
lordlycastle / xmlToJson.js
Created April 12, 2021 20:30 — forked from erickoledadevrel/xmlToJson.js
A function to convert an XML string to a JSON object in Apps Script, using logic similar to the sunset method Xml.parse().
/**
* Converts an XML string to a JSON object, using logic similar to the
* sunset method Xml.parse().
* @param {string} xml The XML to parse.
* @returns {Object} The parsed XML.
*/
function xmlToJson(xml) {
var doc = XmlService.parse(xml);
var result = {};
var root = doc.getRootElement();
@lordlycastle
lordlycastle / apps_install.sh
Created February 10, 2021 19:49 — forked from brunofbrito/apps_install.sh
Install my macOS apps with homebrew, cask and mas-cli
#!/bin/sh
echo Install all AppStore Apps at first!
read -p "Press any key to continue... " -n1 -s
echo '\n'
echo Installing Homebrew...
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo Installing Brew favorites...
brew tap homebrew/cask-fonts
function propertyOverwriteToOverwriteFunction1<T>(
overwrite: DeepPartial<T>
): (defaultData: T) => T {
return defaultData => lodash.merge({}, defaultData, overwrite);
}
function propertyOverwriteToOverwriteFunction2<T>(
overwrite: T
): <A extends T>(defaultData: A) => A {
return defaultData => lodash.merge({}, defaultData, overwrite);
}
@lordlycastle
lordlycastle / SnakeToCamelCase.ts
Last active July 16, 2021 17:21
Creates a new type that allows you to convert object's properties' case from `snake_case` to `camelCase`. This could be useful for reducing code duplication when you need respective model for TS code (camelCase) and REST request/response (JSON; snake_case).
type DB = {aaa_bbb: string, ccc_ddd_eee_fff: number};
type TS = {ab: string, cd: number};
declare function toTS(db: DB): TS; // etc....
type ArrayElementType<T> = T extends (infer E)[] ? E : never;
const el1: ArrayElementType<string[]> = 'hello';
const el2: ArrayElementType<string[]> = 1;
@lordlycastle
lordlycastle / AddPropertyCurried.ts
Last active July 16, 2021 17:50
Create a function that allows you to add required properties to an object one by one. This can reduce common TS pain where you do have all required properties at object instantiation time.
import { compose } from 'rambda';
class Test {
public static sayHello() {
console.log('Hello World!');
}
}
interface Test1 {
a: string
@lordlycastle
lordlycastle / create-dmg.sh
Created January 18, 2021 14:11
Script to create Disk Images on macOS.
#! /bin/bash
# Create a read-only disk image of the contents of a folder
set -e;
function pure_version() {
echo '1.0.0.2'
}
@lordlycastle
lordlycastle / options.sh
Created November 27, 2020 21:52
Bash script to prompt user to choose from list of options. (Bash makes everything so hard.)
#!/usr/local/bin/bash
stty -echo
tput civis
function cleanup() {
stty echo
tput cnorm
}
@lordlycastle
lordlycastle / checkmark-emojifier.js
Last active October 29, 2020 17:36
Replaces any 'x' in Google spreadsheet with a 🔀 emoji for the extra pizzazz! ✨
var emojis = [
'😄','😃','😀','😊','☺','😉','😍','😘','😚','😗','😙','😜','😝','😛','😳','😁','😔','😌','😒','😞','😣','😢','😂','😭','😪','😥','😰','😅','😓','😩','😫','😨','😱','😠','😡','😤','😖','😆','😋','😷','😎','😴','😵','😲','😟','😦','😧','😈','👿','😮','😬','😐','😕','😯','😶','😇','😏','😑','👲','👳','👮','👷','💂','👶','👦','👧','👨','👩','👴','👵','👱','👼','👸','😺','😸','😻','😽','😼','🙀','😿','😹','😾','👹','👺','🙈','🙉','🙊','💀','👽','💩','🔥','✨','🌟','💫','💥','💢','💦','💧','💤','💨','👂','👀','👃','👅','👄','👍','👎','👌','👊','✊','✌','👋','✋','👐','👆','👇','👉','👈','🙌','🙏','☝','👏','💪','🚶','🏃','💃','👫','👪','👬','👭','💏','💑','👯','🙆','🙅','💁','🙋','💆','💇','💅','👰','🙎','🙍','🙇','🎩','👑','👒','👟','👞','👡','👠','👢','👕','👔','👚','👗','🎽','👖','👘','👙','💼','👜','👝','👛','👓','🎀','🌂','💄','💛','💙','💜','💚','❤','💔','💗','💓','💕','💖','💞','💘','💌','💋','💍','💎','👤','👥','💬','👣','💭','🐶','🐺','🐱','🐭','🐹','🐰','🐸','🐯','🐨','🐻','🐷','🐽','🐮','🐗','🐵','🐒','🐴','🐑','🐘','🐼','🐧','🐦','🐤','🐥','🐣','🐔','🐍','🐢','🐛','🐝','🐜','🐞','🐌','🐙','🐚','🐠','🐟','🐬','🐳','🐋','🐄','🐏','🐀','🐃','🐅','🐇','🐉','🐎','🐐','🐓','🐕','🐖','🐁','🐂','🐲','🐡','🐊','🐫','🐪','🐆','🐈','🐩','🐾',
var emojis = [
'😄','😃','😀','😊','☺','😉','😍','😘','😚','😗','😙','😜','😝','😛','😳','😁','😔','😌','😒','😞','😣','😢','😂','😭','😪','😥','😰','😅','😓','😩','😫','😨','😱','😠','😡','😤','😖','😆','😋','😷','😎','😴','😵','😲','😟','😦','😧','😈','👿','😮','😬','😐','😕','😯','😶','😇','😏','😑','👲','👳','👮','👷','💂','👶','👦','👧','👨','👩','👴','👵','👱','👼','👸','😺','😸','😻','😽','😼','🙀','😿','😹','😾','👹','👺','🙈','🙉','🙊','💀','👽','💩','🔥','✨','🌟','💫','💥','💢','💦','💧','💤','💨','👂','👀','👃','👅','👄','👍','👎','👌','👊','✊','✌','👋','✋','👐','👆','👇','👉','👈','🙌','🙏','☝','👏','💪','🚶','🏃','💃','👫','👪','👬','👭','💏','💑','👯','🙆','🙅','💁','🙋','💆','💇','💅','👰','🙎','🙍','🙇','🎩','👑','👒','👟','👞','👡','👠','👢','👕','👔','👚','👗','🎽','👖','👘','👙','💼','👜','👝','👛','👓','🎀','🌂','💄','💛','💙','💜','💚','❤','💔','💗','💓','💕','💖','💞','💘','💌','💋','💍','💎','👤','👥','💬','👣','💭','🐶','🐺','🐱','🐭','🐹','🐰','🐸','🐯','🐨','🐻','🐷','🐽','🐮','🐗','🐵','🐒','🐴','🐑','🐘','🐼','🐧','🐦','🐤','🐥','🐣','🐔','🐍','🐢','🐛','🐝','🐜','🐞','🐌','🐙','🐚','🐠','🐟','🐬','🐳','🐋','🐄','🐏','🐀','🐃','🐅','🐇','🐉','🐎','🐐','🐓','🐕','🐖','🐁','🐂','🐲','🐡','🐊','🐫','🐪','🐆','🐈','🐩','🐾',