Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Charles Mutagorama cmutagorama

🎯
Focusing
View GitHub Profile
@cmutagorama
cmutagorama / export-steps.txt
Created Jan 31, 2021
Steps of backing up/exporting database in pgAdmin
View export-steps.txt
Right-click on your table and pick option Backup..
On File Options, set Filepath/Filename and pick PLAIN for Format
Ignore Dump Options #1 tab
In Dump Options #2 tab, check USE INSERT COMMANDS
In Dump Options #2 tab, check Use Column Inserts if you want column names in your inserts.
Hit Backup button
@cmutagorama
cmutagorama / optional-chaining-nullish-coalescing-operators.ts
Last active Jan 31, 2021
Typescript 3.7 introduced 2 amazing operators: Optional chaining and Nullish coalescing here's how to take advantage of them
View optional-chaining-nullish-coalescing-operators.ts
// Before
const val = otherVal !== null && otherVal !== undefined && otherVal.prop !== null && otherVal.prop !== undefined && otherVal.prop.name;
// With optional chaining
const val = otherVal?.prop?.name;
const name = company.employees?.[0]?.name;
// let's say you want to return a undefined value, that's when nullish coalescring operator comes in handy.
const val = otherVal?.prop?.name ?? 'Anonymous';
const name = company.employees?.[0]?.name: 'User';