Skip to content

Instantly share code, notes, and snippets.

View DYW972's full-sized avatar
🖖
Life

Yohan Dunon DYW972

🖖
Life
View GitHub Profile
@gaearon
gaearon / minification.md
Last active January 28, 2025 19:19
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 October 28, 2024 19:15
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 July 13, 2024 16: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 April 8, 2025 08:12
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');
@nherment
nherment / init.d_node-app
Created May 11, 2017 12:39
init.d nodejs app script
#!/bin/sh
USER="nherment"
NODE_ENV="production"
PORT="5000"
APP_DIR="/opt/node-app/latest"
NODE_APP="server.js"
KWARGS=""
APP_NAME="node-app"
PID_DIR="/var/run"
@robertpainsi
robertpainsi / commit-message-guidelines.md
Last active May 7, 2025 20:05
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@scriptingosx
scriptingosx / .bash_profile
Created April 25, 2017 08:17
Sample Environment Variables in bash_profile/bashrc. (See http://scriptingosx.com/2017/04/on-bash-environment-variables/ for details)
# ENVIRONMENT VARIABLES
# add my ~/bin dir to path
PATH=${PATH}:~/bin
export PATH
# simple prompt
# default macOS prompt is: \h:\W \u\$
export PS1="\W \$ "
@helmasaur
helmasaur / license-badges.md
Last active March 1, 2022 16:49 — forked from lukas-h/license-badges.md
Badges de licence pour vos projet

Badges de licence en Markdown

Collection de badges de licence pour le fichier README de vos projets. Copiez-collez facilement le code dessous les badges dans vos fichier au format Markdown.

Notes

  • Les badges sont réalisé avec Shields.io.
  • Ces badges ne remplacent pas les informations concernant vos projets. Il s'agit seulement d'images pour le fichier README afin que les utilisateurs voient en un coup d'œil la licence choisie.

Vous souhaitez qu'une licence soit ajoutée ?

Commentez ce gist ou contactez le créateur du gist original via un commentaire ou via courriel ([email protected])

@wojteklu
wojteklu / clean_code.md
Last active May 9, 2025 18:43
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@dahjelle
dahjelle / pre-commit.sh
Created July 13, 2016 16:48
Pre-commit hook for eslint, linting *only* staged changes.
#!/bin/bash
for file in $(git diff --cached --name-only | grep -E '\.(js|jsx)$')
do
git show ":$file" | node_modules/.bin/eslint --stdin --stdin-filename "$file" # we only want to lint the staged changes, not any un-staged changes
if [ $? -ne 0 ]; then
echo "ESLint failed on staged file '$file'. Please check your code and try again. You can run ESLint manually via npm run eslint."
exit 1 # exit with failure status
fi
done