Skip to content

Instantly share code, notes, and snippets.

View ChristianRich's full-sized avatar

Christian Rich ChristianRich

View GitHub Profile
@ChristianRich
ChristianRich / workflow.yml
Created January 31, 2020 12:36
Github action: Build and deploy static website to AWS S3
name: Build and deploy
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-18.04
strategy:
const myObj = { firstName: 'John', lastName: 'Doe' };
for (const [key, value] of Object.entries(myObj)) {
console.log(`${key} ${value}`); // John Doe
}
@ChristianRich
ChristianRich / js
Created July 21, 2022 15:10
Array methods at a glance
// The filter() method creates a new array filled with elements that pass a test provided by a function
[1, 2, 3, 4, 5].filter((n) => n > 3); // [4,5]
// The find() method returns the value of the first element that passes the test
[1, 2, 3, 4, 5].find((n) => n > 3); // 4
//. The every() method tests whether all elements in the array pass the test implemented by the provided function. It returns a Boolean value.
[1, 30, 39, 29, 10, 34].every((n) => n < 40); // true
@ChristianRich
ChristianRich / .ts
Created October 23, 2022 23:21
Node.js read/write file promise wrapper
import fs from 'fs';
import path from 'path';
export const write = (
data: string,
filename: string,
dir: string = process.cwd(),
): Promise<string> =>
new Promise((resolve, reject) => {
const dest = path.resolve(`${dir}/${filename}`);
@ChristianRich
ChristianRich / ES5-ES6-ES2017-ES2019 omit & pick
Created December 30, 2022 14:17 — forked from bisubus/ES5-ES6-ES2017-ES2019 omit & pick
ES5/ES6/ES2017/ES2019 omit & pick