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 bcrypt = require('bcrypt'); | |
let passwordHash; | |
bcrypt.hash('passwordString', 10, function(err, hash) { | |
passwordHash = hash; | |
}); | |
bcrypt.compare('differentpasswordString', passwordHash, function(err, res) { | |
if(res) { | |
console.log(res) //returns true |
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
import { Grid, Divider, Typography } from '@material-ui/core' | |
//Could use makeStyles here but it's harder to understand | |
const MidText = ({text}) => { | |
return ( <div style={{ padding: '8px' }}> | |
<Grid container> | |
<Grid item style={{ flex: 1, display: 'flex', alignItems: 'center'}}> | |
<Divider style={{ flexGrow: 1 }}/> | |
</Grid> |
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 createPromise = () => { | |
let resolver; | |
return [ new Promise(( resolve, reject ) => { | |
resolver = resolve | |
}), resolver] | |
} |
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
import React, { useState } from 'react' | |
import { Grid, Dialog, DialogContent, DialogActions, Button } from '@material-ui/core' | |
const useConfirm = () => { | |
const [ open, setOpen ] = useState(false); | |
const [ resolver, setResolver ] = useState({ resolver: null }) | |
const [ label, setLabel ] = useState('') | |
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 DeleteWithUseConfirm = () => { | |
const [ getConfirmation, Confirmation ] = useConfirm() | |
const onDelete = async () => { | |
const status = await getConfirmation('Shall we have dinner together tonight?'); | |
if (status) { //status = true | |
...We can now do the job of deleting |
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
/* | |
* Credit to https://blog.maximeheckel.com/posts/static-tweets-with-mdx-nextjs/ | |
*/ | |
import { css } from '@emotion/react'; | |
import { format } from 'date-fns'; | |
import Image from 'next/image'; | |
import { TransformedTweet } from 'types/tweet'; | |
import { LikeIcon, ReplyIcon, RetweetIcon, TwitterLogo } from './Icons'; | |
import { |
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
#!/bin/bash | |
# @link https://gist.github.com/mattscilipoti/8424018 | |
# | |
# Called by "git push" after it has checked the remote status, | |
# but before anything has been pushed. | |
# | |
# If this script exits with a non-zero status nothing will be pushed. | |
# | |
# Steps to install, from the root directory of your repo... |
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
/** | |
* @param {object} obj plain object with { key: value } | |
* @param {array} keysToCheck List of keys to check for undefined values e.g. ['a','b','c'] | |
* @example | |
* | |
* const obj = { a: undefined, b: 1, c: 2, d: undefined } | |
* | |
* console.log(keysUndefined(obj)) | |
* returns ['a','d' ] | |
**/ |
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
/* | |
Go-Language implementation of an SSH Reverse Tunnel, the equivalent of below SSH command: | |
ssh -R 8080:127.0.0.1:8080 operatore@146.148.22.123 | |
which opens a tunnel between the two endpoints and permit to exchange information on this direction: | |
server:8080 -----> client:8080 |
OlderNewer