Skip to content

Instantly share code, notes, and snippets.

View simonrenoult's full-sized avatar
🏠
Working from home

Simon Renoult simonrenoult

🏠
Working from home
View GitHub Profile
$> mysql --host=127.0.0.1 --protocol=TCP --user=root --password=password
mysql> SET GLOBAL log_output=FILE;
mysql> SET GLOBAL log_queries_not_using_indexes=ON;
mysql> SET GLOBAL long_query_time=0.1;
mysql> SET GLOBAL slow_query_log=ON;
mysql> SET GLOBAL slow_query_log_file='/var/log/mysql/slow-query.log';
$> mysql --host=127.0.0.1 --protocol=TCP --user=root --password=password
mysql> SET GLOBAL log_output=FILE;
mysql> SET GLOBAL log_queries_not_using_indexes=ON;
mysql> SET GLOBAL long_query_time=0.1;
mysql> SET GLOBAL slow_query_log=ON;
mysql> SET GLOBAL slow_query_log_file='/var/log/mysql/slow-query.log';
# Time: 2019-06-26T10:32:05.868845Z
# User@Host: root[root] @ [172.17.0.1] Id: 2
# Query_time: 0.000411 Lock_time: 0.000136 Rows_sent: 0 Rows_examined: 0
use debug_sql;
SET timestamp=1561545125;
select * from articles;
mysql> SELECT * FROM articles;
+------------+-----------------------------+-----------------+
| article_id | article_title | article_content |
+------------+-----------------------------+-----------------+
| 1 | Les tomates en Provence | Lorem ipsum... |
| 2 | Les courgettes de Normandie | Lorem ipsum... |
| 3 | Les pommes de Lorraine | Lorem ipsum... |
| 4 | Les poires de Paris | Lorem ipsum... |
| ... | ... | ... |
| 999986 | La menthe de Bretagne | Lorem ipsum... |
@simonrenoult
simonrenoult / LogExecutionTime.java
Last active February 26, 2019 16:38
Log Execution Time
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface LogExecutionTime {
/**
* Returns the kind of execution time to log
*
* @return the kind of execution time to log
*/
String kind() default "-";
#!/usr/bin/env sh
# Warning! This script is a work in progress.
#
# The sript is buggy since logout/restarts are needed between some steps (zsh or docker I guess)
# but it's a good reminder of what needs to be done to setup a new machine.
main () {
install_prerequisites
install_and_configure_zsh
@simonrenoult
simonrenoult / http-patch.md
Last active November 12, 2018 08:41
Exemple d'un requête PATCH non-idempotente

Etant donné la ressource :

GET /articles/1234 HTTP/1.1

HTTP/1.1 200 OK
{ "title": "PUT vs PATCH","tags": ["http", "api", "rest"] }

Si j'exécute plusieurs fois la requête PATCH d'ajout d'un tag via le format [JSON Patch] (sans l'utilisation d'un etag)

@simonrenoult
simonrenoult / new_project.sh
Last active March 1, 2019 09:32
Script to bootstrap a nodejs project
project_name=$1
project_description=$2
location=$HOME/code/$project_name
pkg=$location/package.json
readme=$location/readme.md
node_version=$(node --version)
npm_version=$(npm --version)
if [ -z "$project_name" ]; then
echo "Error: a project name must be provided."
const orderData = Object.assign(
{
total_amount: totalAmount,
shipment_amount: orderShipmentPrice,
total_weight: orderTotalWeight
},
{ product_list: req.body.product_list }
);
const SHIPMENT_PRICE_STEP = 25;
const SHIPMENT_WEIGHT_STEP = 10;
const orderShipmentPrice = SHIPMENT_PRICE_STEP * Math.round(orderTotalWeight / SHIPMENT_WEIGHT_STEP);
let totalAmount = orderProductListPrice + orderShipmentPrice;