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';
@simonrenoult
simonrenoult / timeout.js
Last active Jan 25, 2021
Managing timeout. Especially handy with autocomplete.
View timeout.js
// Props to : http://nathanleclaire.com/blog/2013/11/16/the-javascript-question-i-bombed-in-an-interview-with-a-y-combinator-startup/
var processOnTime = function ( next, delay ) {
var d = delay;
if ( ! next ) {
throw new ReferenceError();
}
if ( ! d || isNaN ( d ) ) {
d = 200;
@simonrenoult
simonrenoult / sanitize.js
Last active Nov 30, 2020
Recursive trim of objects and arrays using lodash
View sanitize.js
function sanitize(object) {
if (_.isString(object)) return _sanitizeString(object);
if (_.isArray(object)) return _sanitizeArray(object);
if (_.isPlainObject(object)) return _sanitizeObject(object);
return object;
}
function _sanitizeString(string) {
return _.isEmpty(string) ? null : string;
}
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
View .zshrc
export PATH=$HOME/bin:/usr/local/bin:$PATH
export ZSH="$HOME/.oh-my-zsh"
ZSH_THEME="avit"
HYPHEN_INSENSITIVE="true"
COMPLETION_WAITING_DOTS="true"
plugins=(autojump common-aliases docker extract httpie docker docker-compose kubectl)
source $ZSH/oh-my-zsh.sh
View HealthcheckApi.java
@RestController
public class HealthcheckApi {
private final SayImAlive sayImAlive;
public HealthcheckApi(SayImAlive sayImAlive) {
this.sayImAlive = sayImAlive;
}
@RequestMapping(value = "/healthcheck")
View script.sh
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o xtrace
# Script goes here...
View explain_select_with_quotes.sql
mysql> EXPLAIN SELECT SQL_NO_CACHE * FROM articles WHERE article_id = '150001';
+----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
| id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra |
+----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
| 1 | SIMPLE | articles | NULL | const | PRIMARY | PRIMARY | 34 | const | 1 | 100.00 | NULL |
+----+-------------+----------+------------+-------+---------------+---------+---------+-------+------+----------+-------+
1 row in set, 1 warning (0.00 sec)
View select_with_quotes.sql
mysql> SELECT SQL_NO_CACHE * FROM articles WHERE article_id = '150000';
+------------+---------------+-----------------+
| article_id | article_title | article_content |
+------------+---------------+-----------------+
| 150000 | Title 150000 | Content 150000 |
+------------+---------------+-----------------+
1 row in set (0.00 sec)
View select_without_quote.sql
mysql> SELECT SQL_NO_CACHE * FROM articles WHERE article_id = 150000;