Skip to content

Instantly share code, notes, and snippets.

View DYW972's full-sized avatar
🖖
Life

Yohan Dunon DYW972

🖖
Life
  • Design Your Web
  • France
View GitHub Profile
@koficoud
koficoud / mongodb_pass_reset.md
Last active July 21, 2023 07:27 — forked from shivampip/mongodb_pass_reset.md
MongoDB shell admin password reset
  • open mongod.conf
sudo nano /etc/mongod.conf
  • Comment security
#security:
#  authroization: "enabled"
@habovh
habovh / zshrc_Apple_Terminal
Last active April 7, 2021 14:30
ZSH + Apple Terminal: set tab title current working directory for Mojave and earlier
# This is a slightly modified version of Mojave (10.14) script located in /etc/bashrc_Apple_Terminal
# modified to work with zsh.
# It mainly calls update_terminal_cwd when changing the working directory, which prints a special
# invisible string that Apple Terminal interprets and updates the current term title accordingly.
# Note : this script is useless for macOS Catalina and newer versions of macOS, since it should
# already contain at least this functionality.
# Instructions
# Place this file in /etc/ (alongside bash_Apple_Terminal)
@scriptingosx
scriptingosx / bash_prompt.sh
Last active June 23, 2022 19:13
Sample code for dynamic bash prompt that shows exit codes.
# PROMPT
# default macOS prompt is: \h:\W \u\$
# assemble the prompt string PS1
# inspired from: https://stackoverflow.com/a/16715681
function __build_prompt {
local EXIT="$?" # store current exit code
# define some colors
@DavidWells
DavidWells / async-await-node-style-promises.js
Last active June 30, 2023 14:08
Nicer business logic with async wait promises that won't swallow native JS errors. Update to https://gist.github.com/DavidWells/54f9dd1af4a489e5f1358f33ce59e8ad where we handle native JS errors instead of potentially missing them. Now a package here https://www.npmjs.com/package/safe-await
/* Native Error types https://mzl.la/2Veh3TR */
const nativeExceptions = [
EvalError, RangeError, ReferenceError, SyntaxError, TypeError, URIError
].filter((except) => typeof except === 'function')
/* Throw native errors. ref: https://bit.ly/2VsoCGE */
function throwNative(error) {
for (const Exception of nativeExceptions) {
if (error instanceof Exception) throw error
}
/* Helper buddy for removing async/await try/catch litter 🗑 */
function O_o(promise) {
return promise.then(data => {
if (data instanceof Error) return [data]
return [null, data]
}).catch(err => [err])
}
/* Look ma, no try/catch */
async function usageExample(params) {
#!/usr/bin/env bash
echo "
----------------------
NODE & NPM
----------------------
"
# add nodejs 10 ppa (personal package archive) from nodesource
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
@gaearon
gaearon / minification.md
Last active March 4, 2024 12:45
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@ywwwtseng
ywwwtseng / host-react-app-on-apache-server.md
Last active May 3, 2024 15:52
Host react application on Apache server

Host react application on Apache server

Step 1 : Create your app

$ npm install -g create-react-app 
$ create-react-app my-app

Step 2 : Build it for production

@laurenfazah
laurenfazah / authentication_with_express_postgres.md
Last active November 8, 2022 01:51
Authentication with an Express API and Postgres

Authentication with an Express API and Postgres

Setting Up

Let's make sure our Express app has the required base modules:

# within root of API
npm install --save express pg knex bcrypt
npm install --save-dev nodemon
@ziluvatar
ziluvatar / token-generator.js
Last active May 21, 2024 12:44
Example of refreshing tokens with jwt
/**
* Example to refresh tokens using https://github.com/auth0/node-jsonwebtoken
* It was requested to be introduced at as part of the jsonwebtoken library,
* since we feel it does not add too much value but it will add code to mantain
* we won't include it.
*
* I create this gist just to help those who want to auto-refresh JWTs.
*/
const jwt = require('jsonwebtoken');