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 SALT_WORK_FACTOR = 10; | |
UserSchema.pre('insertMany', async (next, users) => { | |
if (Array.isArray(users) && users.length > 0) { | |
const hashedUsers = users.map(async (user) => { | |
return await new Promise((resolve, reject) => { | |
bcrypt | |
.genSalt(SALT_WORK_FACTOR) | |
.then((salt) => { | |
bcrypt | |
.hash(user.password.toString(), salt) |
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
-- | |
-- PostgreSQL database dump | |
-- | |
-- Dumped from database version 12.9 (Ubuntu 12.9-2.pgdg20.04+1) | |
-- Dumped by pg_dump version 12.9 (Ubuntu 12.9-2.pgdg20.04+1) | |
SET statement_timeout = 0; | |
SET lock_timeout = 0; | |
SET idle_in_transaction_session_timeout = 0; |
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
/* | |
---------------From-------------------------- | |
<Row className='row-class'> | |
<Col sm={5} className='col1-class'> | |
<p>col 1</p> | |
</Col> | |
<Col sm={5} className='col2-class'> | |
<p>col 2</p> | |
</Col> | |
</Row> |
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
export const capitalCase = (str) => | |
str && | |
str.toString().charAt(0).toUpperCase() | |
+ str.toString().slice(1).toLowerCase(); | |
export const properCase = (str) => | |
str && | |
str | |
.toString() | |
.split(' ') |
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
/* | |
56 = 56 | |
56,000 = 56K | |
56,00,000 = 56Lac | |
56,000,000 = 56M | |
56,00,00,000 = 56Crore | |
56,000,000,000 = 56B | |
56,000,000,000,000 = 56T | |
*/ |
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 | |
# Script to insert data from courses.csv and students.csv into students database | |
PSQL="psql -X --username=freecodecamp --dbname=students --no-align --tuples-only -c" | |
echo $($PSQL "TRUNCATE students, majors, courses, majors_courses") | |
cat courses.csv | while IFS="," read MAJOR COURSE | |
do | |
if [[ $MAJOR != "major" ]] |
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 | |
# Bingo Number Generator | |
echo -e "\n~~ Bingo Number Generator ~~\n" | |
NUMBER=$(( RANDOM % 75 + 1 )) | |
TEXT="The next number is, " | |
if (( NUMBER <= 15 )) |
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
Show hidden characters
{ | |
"ue: useEffect Hook": { | |
"prefix": "ue", | |
"body": ["useEffect(() => {", " ${1:code}", "}, []);", ""], | |
"description": "ue: useEffect Hook" | |
}, | |
"us: New state variable using useState Hook": { | |
"prefix": "us", | |
"body": [ | |
"const [$1, set${1/(^.|.+$)/${1:/upcase}/}] = useState(${2:defaultValue});", |
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
@mixin size($width-param, $height-param:0) { | |
width: $width-param; | |
@if $height-param !=0 { | |
height: $height-param; | |
} | |
@else { | |
height: $width-param; | |
} |
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
def docx_replace(doc, data): | |
paragraphs = list(doc.paragraphs) | |
for t in doc.tables: | |
for row in t.rows: | |
for cell in row.cells: | |
for paragraph in cell.paragraphs: | |
paragraphs.append(paragraph) | |
for p in paragraphs: | |
for key, val in data.items(): | |
key_name = '${{{}}}'.format(key) # use placeholders in the form ${PlaceholderName} |