Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Simon Renoult simonrenoult

🏠
Working from home
View GitHub Profile
View slow_query_log_configuration.sql
$> 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';
View slow_query_log_configuration.sql
$> 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';
View slow_query_log.sql
# 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;
View select_all.sql
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... |
View LogExecutionTime.java
@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 "-";
View linux_setup.sh
#!/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 Nov 12, 2018
Exemple d'un requête PATCH non-idempotente
View http-patch.md

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 Mar 1, 2019
Script to bootstrap a nodejs project
View new_project.sh
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."
View clean-node-1-excerpt-14.js
const orderData = Object.assign(
{
total_amount: totalAmount,
shipment_amount: orderShipmentPrice,
total_weight: orderTotalWeight
},
{ product_list: req.body.product_list }
);
View clean-node-1-excerpt-13.js
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;