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 / bookmarklet.js
Created September 28, 2018 12:15
Simple JS Bookmarket to got to the download page of you-T-ubemonkey
javascript:void(
function(){
var u = 'https://www.you'+'tu'+'bemonkey.com'+ window.location.pathname + window.location.search;
window.location = u;
}()
);
@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);
@iArnaud
iArnaud / README.md
Created September 9, 2014 12:05
COUNTRY CODES IN YAML FORMAT

COUNTRY CODES IN YAML FORMAT

Here are all the country codes in YAML format for your downloading pleasure! You may place them in your app.yml (for symfony users) and call the list with sfConfig::get(‘app_countries’).