Skip to content

Instantly share code, notes, and snippets.

View renshuki's full-sized avatar
💭
🇫🇷 🇯🇵 🇺🇸

Francois-Clement Brossard renshuki

💭
🇫🇷 🇯🇵 🇺🇸
View GitHub Profile
@renshuki
renshuki / ubuntu_agnoster_install.md
Last active April 23, 2024 13:04
Ubuntu 16.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

@renshuki
renshuki / elasticsearch-bulk-index-from-json-hits.md
Last active March 4, 2024 13:23
Elasticsearch - Bulk index from a JSON file hits (with jq)
cat file.json | jq -c '.hits.hits[] | { index: {_index:._index, _type:._type, _id:._id}}, ._source' | curl -XPOST -H "Content-Type: application/x-ndjson" localhost:9200/_bulk --data-binary @- | jq .
@renshuki
renshuki / recalculate-acf-locations.php
Last active July 7, 2023 01:15 — forked from RadGH/recalculate-acf-locations.php
Update ACF location fields (Google Map) after WP All Import CSV import (Google map update not triggered correctly) - Credits: https://support.advancedcustomfields.com/forums/topic/how-to-update-google-map-latitudelongitude-after-importing-using-address/
<?php
global $ld_recalc;
global $geolocate_api_key;
$geolocate_api_key = "YOUR_GOOGLE_GEOLOCATE_API_KEY";
$ld_recalc = array(
'posts_per_run' => 16,
'post_types' => array( 'distributor' ),
@renshuki
renshuki / painless_script_compare_current_date_with_index_date.md
Created October 16, 2019 08:57
Elasticsearch - Painless script to compare the current date with a date already indexed into a document

Elasticsearch Painless script which aims to calculate the difference in days between a date indexed into a document and the current date.

GET days_compare/_search
{
  "script_fields": {
    "diffdate": {
      "script": {
        "lang":   "painless",
 "source": """
@renshuki
renshuki / kibana_err_cert_common_name_invalid.md
Created May 19, 2022 07:17
Kibana NET::ERR_CERT_COMMON_NAME_INVALID error

If you get a NET::ERR_CERT_COMMON_NAME_INVALID when trying to connect to Kibana from your browser, it means the CN and/or SAN you defined at the certificate generation is incorrect. Please refer to the Encrypt traffic between your browser and Kibana documentation for more details on how to properly generate a server certificate for Kibana.

@renshuki
renshuki / elasticsearch-threadpool-size-details.md
Last active May 10, 2022 13:30
Elasticsearch threadpool size details using _cat/thread_pool API

Run GET _cat/thread_pool?v&h=node_name,name,max,pool_size,size,type,queue_size

Gives you details on Elasticsearch threadpool size, type, queue_size.

Example output

node_name           name                                    max pool_size size type                  queue_size
instance-0000000009 analyze                                             0    1 fixed                         16
instance-0000000009 ccr                                                32   32 fixed                        100
@renshuki
renshuki / wordpress_tag_search.md
Last active November 1, 2021 18:42
Wordpress SQL query to find posts having both tags

Please replace TAG ID 1 and TAG ID 2 by the tags you are looking for.

SELECT p.id
FROM wp_posts AS p
JOIN wp_term_relationships AS tr ON p.id = tr.object_id
JOIN wp_term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
JOIN wp_terms AS t ON tt.term_id = t.term_id
WHERE t.term_id=_TAG ID 1_ OR t.term_id=_TAG ID 2_ AND p.post_type LIKE 'post'
GROUP BY p.id
@renshuki
renshuki / elasticsearch_filedatavisualizer_geopoint_ingest_pipeline_conversion.md
Created September 27, 2019 11:05
Elasticsearch CSV import via File Data Visualizer (ML) - Convert latitude and longitude column to geo_point using ingest pipeline
  1. Choose your CSV file to import including your coordinates data and upload it

location.csv

lat,long, timestamp
41.12,-71.34,1569476964
38.85896,-106.01665,1569476964
65.47629,18.61576,1569476964
@renshuki
renshuki / kibana-legacy-data-table-visualization.md
Created August 13, 2021 04:35
Enable Kibana legacy data table visualization (prior to EUI datagrid)

Add vis_type_table.legacyVisEnabled: true to kibana.yml

@renshuki
renshuki / elasticsearch_slowlog_for_all_indices.md
Created May 11, 2019 08:51
How to enable slowlogs for all indices and tweak slowlog logger level

Slowlog thresholds for all indices

Add slowlog thresholds for all indices

PUT /_all/_settings 
{
"index.search.slowlog.threshold.query.warn": "10s",
"index.search.slowlog.threshold.query.info": "5s",
"index.search.slowlog.threshold.query.debug": "2s",