Skip to content

Instantly share code, notes, and snippets.

@iArnaud
iArnaud / mysql-docker.sh
Created July 26, 2021 08:16 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@iArnaud
iArnaud / brute-force-protection-by-username-and-ip-plus-username.js
Created October 17, 2019 10:57 — forked from animir/brute-force-protection-by-username-and-ip-plus-username.js
Node.js rate-limiter-flexible. Brute-force protection - Block source of requests by IP, Username+IP and Username.
const http = require('http');
const express = require('express');
const redis = require('redis');
const { RateLimiterRedis } = require('rate-limiter-flexible');
const redisClient = redis.createClient({
enable_offline_queue: false,
});
const maxWrongAttemptsByIPperDay = 100;
const maxConsecutiveFailsByUsernameAndIP = 10;
@iArnaud
iArnaud / git_commands.sh
Created March 14, 2019 13:07 — forked from jamischarles/git_commands.sh
Git cheat sheet
- my normal flow?
- good commit messages ******
- searching commit messages (group by keywords)
- searching code *
- working with history (viewing, time traveling)
- rebasing (for pulling & squashing, splitting a commit) *
- undoing local commits (soft, hard reset)
- forgot to add / change message (amend)
- LOST commits? *
@iArnaud
iArnaud / 1-securing-express.md
Created March 14, 2019 13:01 — forked from cerebrl/1-securing-express.md
Securing ExpressJS

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.
@iArnaud
iArnaud / tips.js
Created March 14, 2019 12:56 — forked from denneulin/tips.js
Tips
const _ = require('lodash');
const str = '1dé@#j. à$42^ù`=:/+%M£¨-)àç!Їжакè§("^é& vu';
// exclude all special characters and spaces in a string
const result = _.deburr(str).replace(/\W/g, '');
// result = 1deja42uMaceevu
// exclude all special characters and replaces spaces by underscore in a string
// N spaces side by side = 1 underscore
const result = _.deburr(str).replace(/[^\w\s]/g, '').trim().replace(/\s+/g, '_');
@iArnaud
iArnaud / pre-commit
Last active August 29, 2015 14:13 — forked from phpfunk/pre-commit
#!/usr/bin/php
<?php
// Set empty files array
$files = array();
// Get untracked files
// Get modified files
exec('git ls-files --others --exclude-standard', $untracked);
exec('git diff --cached --diff-filter=ACMRTUX --name-only', $modified);

#List of countries

It's time someone compiled a list of countries to use within a web application. This gist attempts to make a first move at that.

List of nationalities

I've also compiled a list of nationalities

<div class="container"><h3>.row-flex (make columns equal heights in each row)</h3></div>
<div class="container">
<div class="row row-flex row-flex-wrap">
<div class="col-md-3">
<div class="panel panel-default flex-col">
<div class="panel-heading">Title flex-col</div>
<div class="panel-body flex-grow">Content here -- div with .flex-grow</div>
<div class="panel-footer">Footer</div>
</div>
</div>