Skip to content

Instantly share code, notes, and snippets.

View arnaud-zg's full-sized avatar
🎯
Focusing

Arnaud Zheng arnaud-zg

🎯
Focusing
View GitHub Profile
/**
* To run this script:
* npx tsx ./react-colocation-example-1.ts
*/
// Product type
interface Product {
id: string;
price: number;
quantity: number;
@arnaud-zg
arnaud-zg / introrx.md
Created March 28, 2023 13:28 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@arnaud-zg
arnaud-zg / top-brew-packages.txt
Created December 9, 2022 12:37 — forked from r5v9/top-brew-packages.txt
Top homebrew packages
node: Platform built on V8 to build network applications
git: Distributed revision control system
wget: Internet file retriever
yarn: JavaScript package manager
python3: Interpreted, interactive, object-oriented programming language
python: Interpreted, interactive, object-oriented programming language
mysql: Open source relational database management system
coreutils: GNU File, Shell, and Text utilities
openssl: SSL/TLS cryptography library
postgresql: Object-relational database system
@arnaud-zg
arnaud-zg / asyncCheatsheet.js
Created September 10, 2022 19:47 — forked from jicking/asyncCheatsheet.js
async patterns cheatsheet
// hell
function hell() {
step1(a => {
step2(b => {
return a + b
})
})
}
// heaven
const data = [1,2,3,4,5,6,7,8,9,10,1,2,3]
const findDuplicates = (data) => {
const hashMap = {}
data.forEach((value) => {
hashMap[value] = (hashMap[value] || 0) + 1
})
return Object.entries(hashMap).reduce((acc, [value, nbOfItems]) => {
if (nbOfItems <= 1) {
@arnaud-zg
arnaud-zg / guide.md
Created December 12, 2019 14:19 — forked from mindlapse/guide.md
A guide on how to use PaymentIntents with tipsi-stripe

Introduction

Card payments with Stripe should be performed with PaymentIntents.

This API was created to handle modern payments, where the cardholder's bank may require the user to authenticate themselves with the bank before a payment can be authorized.

Authentication requirements first started to appear with European banks regulated by PSD2 which introduced [Strong Customer Authentication

const getArrayCombinations = array => {
let combinations = []
for (let i = 0; i < array.length - 1; i++) {
for (let j = i + 1; j < array.length; j++) {
combinations.push([
{
value: array[i],
position: i,
},
export const getNextQuarterHourFromDate = (date: Date) => {
const dateToReturn = new Date(date)
dateToReturn.setSeconds(0)
dateToReturn.setMinutes(Math.ceil(dateToReturn.getMinutes() / 15) * 15)
return dateToReturn
}
console.log({
scenario: "getNextQuarterHourFromDate(new Date('1995-12-17T03:00:00.000Z'))",
interface IComments {
id: number,
children?: IComments
parentId: number | null,
content: string
}
const nest = (items, id = null, linkKey = 'parentId') => (
items
.filter((item) => item[linkKey] === id)
var capitalize = function(value) {
return value.replace(/\b\w/g, function(match) { return match.toUpperCase(); })
}