Skip to content

Instantly share code, notes, and snippets.

View idoqo's full-sized avatar

Michael Okoko idoqo

View GitHub Profile
@idoqo
idoqo / wagers.json
Created July 11, 2023 11:42
wagers response
{
"pagination": {
"page": 1,
"size": 22,
"lastPage": 1,
"totalCount": 22
},
"wagers": [
{
"id": "e5ea9cdd-a0eb-4439-b01f-2fbda9e2e981",
@idoqo
idoqo / mtls.md
Last active September 24, 2021 11:17
What is MTLS?

What is MTLS?

You’ve probably heard about TLS. It is a security protocol that sits between the transport and application layers (in the TCP/IP model) and essentially encrypts application-layer traffic. This encryption provides a guarantee to the client that:

  • The server is who they say they are.
  • Its communication with the server is confidential and cannot be spied on by a third party.
  • Data received is untouched/unmodified along the way.

The regular TLS achieves all three above with a caveat - it provides no guarantee to the server that the client is who they say they are. As a result, verifying the client is done by the application using techniques like basic authentication (using usernames and passwords), Bearer/Access Tokens, or mutual TLS.

Like TLS, but mutual

diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result
index a56cb113af9..7c3ce298d22 100644
--- a/mysql-test/main/statistics_json.result
+++ b/mysql-test/main/statistics_json.result
@@ -232,12 +232,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 0 49 0.0000 1.0000 4 JSON 5B0A20202239222C0A2020223139222C0A2020223331222C0A2020223430220A5D
+test t1 a 0 49 0.0000 1.0000 4 JSON 5B0A20202230222C0A2020223139222C0A2020223331222C0A2020223430220A5D

Introduction

The overall goal of the project is to add support for storing histogram statistics on disk in JSON format. As described in the related Jira page, storing histograms in comes with some benefits like:

  • Allow DBAs to examine (and modify) the histograms. For instance, they can take advantage of existing JSON_* functions like JSON_LENGTH and JSON_EXTRACT to examine the generated histograms.
  • Improve the histogram precision especially for VARCHAR data types.
  • Provide a base for other histogram formats such as most-common-values (MCV).

NB: Below, "binary histograms" is used to refer to both single and double precision histograms (i.e SINGLE_PREC_HB and DOUBLE_PREC_HB).

Relevant Links

  • MDEV-21130 - Tracking JIRA page for this project's issue.
  • MDEV-26125 - Sample bug demonstrating a limitation in the current binary histogram.
create table users (
city varchar(100)
);
insert into users select 'Moscow' from seq_1_to_99;
insert into users select 'Helsinki' from seq_1_to_2;
analyze table users persistent for all;
Table Op Msg_type Msg_text
test.users analyze status Engine-independent statistics collected
test.users analyze status OK
select decode_histogram(hist_type, histogram) from mysql.column_stats where table_name='users';
https://svg-path-visualizer.netlify.app/#m%20430.17%2C723%202.4%2C-5.59%20h%20-3.24%20v%20-1.31%20h%204.84%20v%201.08%20l%20-2.41%2C5.82%20z%20m%207.388%2C0%20v%20-1.42%20h%20-3.13%20v%20-1.14%20l%202.94%2C-4.34%20h%201.56%20v%204.28%20h%200.77%20v%201.2%20h%20-0.77%20V%20723%20Z%20m%20-1.78%2C-2.62%20h%201.78%20v%20-2.6%20z%20m%207.487%2C2.77%20c%20-0.42%2C0%20-0.8%2C-0.08%20-1.14%2C-0.24%20-0.34%2C-0.16%20-0.633%2C-0.387%20-0.88%2C-0.68%20-0.247%2C-0.3%20-0.437%2C-0.653%20-0.57%2C-1.06%20-0.133%2C-0.407%20-0.2%2C-0.86%20-0.2%2C-1.36%200%2C-0.573%200.077%2C-1.097%200.23%2C-1.57%200.153%2C-0.473%200.373%2C-0.88%200.66%2C-1.22%200.287%2C-0.34%200.623%2C-0.603%201.01%2C-0.79%200.393%2C-0.187%200.83%2C-0.28%201.31%2C-0.28%200.3%2C0%200.59%2C0.04%200.87%2C0.12%200.28%2C0.073%200.543%2C0.183%200.79%2C0.33%20l%20-0.38%2C1.18%20c%20-0.147%2C-0.1%20-0.33%2C-0.18%20-0.55%2C-0.24%20-0.22%2C-0.06%20-0.437%2C-0.09%20-0.65%2C-0.09%20-0.34%2C0%20-0.64%2C0.083%20-0.9%2C0.25%20-0.26%2C0.16%20-0.473%2C0.39%20-0.64%2C0.69%20-0
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>Landing Page</title>
</head>
<body>
@idoqo
idoqo / zshrc
Created November 24, 2020 15:39
zsh config
#
# Executes commands at the start of an interactive session.
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# Source Prezto.
if [[ -s "${ZDOTDIR:-$HOME}/.zprezto/init.zsh" ]]; then
source "${ZDOTDIR:-$HOME}/.zprezto/init.zsh"
@idoqo
idoqo / db-middleware.go
Created July 24, 2020 16:48
Middleware to send a database instance as chi middleware
func dbContext(db database.Database) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ctx := context.WithValue(r.Context(), databaseKey, db)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
}
/* USAGE*/