psql -U postgres -c 'SHOW config_file'
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
// helps us in parsing the frontmatter from text content | |
const matter = require('gray-matter') | |
// helps us safely stringigy the frontmatter as a json object | |
const stringifyObject = require('stringify-object') | |
// helps us in getting the reading time for a given text | |
const readingTime = require('reading-time') | |
// please make sure you have installed these dependencies | |
// before proceeding further, or remove the require statements | |
// that you don't use |
stores to a local db called ~/.password-store
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 minLength = (min) => (str) => (str||'').toString().trim().length >= min | |
const contains = (chars, min) => (str) => [...((str||'').toString().trim())].filter(char => (new Set(chars)).has(char)).length >= min | |
const hasLowerCase = contains('abcdefghijklmnopqrstuvwxyz', 1) | |
const hasUpperCase = contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 1) | |
const hasNumber = contains('0123456789', 1) | |
const hasSpecialChar = contains('!@#$%^&*()-+_', 1) | |
const compose = (...fns) => (x) => fns.map((fn) => fn(x)) | |
const passwordPolicyCheck = compose( | |
minLength(12), | |
hasLowerCase, |
Client | Server |
---|---|
Use React hooks such as useState, useEffect, useReducer | Fetch Data |
Interactivity within the component, with event listeners (onClick()) | Store sensitive information on server (tokens, API keys, etc.) |
Use custom hooks that depend on state, effects. | Access backend resources directly |
Keep large dependencies on the server |
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
/** | |
* Problem: an array of data, that has an array of sub data. | |
* Three ways to do this: | |
* - map+split, reduce, push+spread, sort ( side effect: order is not retained ) | |
* - map+split, flat | |
* - flatMap+split | |
*/ | |
const values = 'a|b|c|d,e|f,g|h|i|j|k|l' | |
const A = values.split(',').map((v)=>v.split('|')).reduce((acc,v)=>{ |
Currying is the process of turning a function that expects multiple parameters into one that, when supplied fewer parameters, returns a new function that awaits the remaining ones. [1]