Skip to content

Instantly share code, notes, and snippets.

View fdv's full-sized avatar
🚀
Taking over the world

Fred de Villamil fdv

🚀
Taking over the world
View GitHub Profile
# Mass index deletion with pattern
for index in $(curl -XGET esmaster:9200/_cat/indices | grep pattern | awk '{print $3}'); do curl -XDELETE esmaster:9200/$index?master_timeout=120s; done
# Mass optimize, indexes with the most deleted docs first
for indice in $(CURL -XGET esmaster:9200/_cat/indices | sort -rk 7 | awk '{print $3}'); do curl -XPOST http://esmaster:9200/${indice}/_optimize?max_num_segments=1; done
# Restart half a cluster using rack awareness
curl -XPUT 'host:9200/_cluster/settings' -d '{ "transient" : { "cluster.routing.allocation.enable": "none" }}'; for host in $(curl -XGET esmaster:9200/_cat/nodeattrs?attr | grep rack_id | awk '{print $2}'); do ssh $host service elasticsearch restart; done; sleep60; curl -XPUT 'host:9200/_cluster/settings' -d '{ "transient" : { "cluster.routing.allocation.enable": "all }}'
@fdv
fdv / esrestart.sh
Created November 4, 2016 18:08
Elasticsearch restart config
# normal
curl -XPUT 'http://esmaster01.:9200/_cluster/settings' -d '{
"transient" : {
"cluster.routing.allocation.cluster_concurrent_rebalance": 50,
"indices.recovery.concurrent_streams": 50,
"cluster.routing.allocation.node_initial_primaries_recoveries": 50,
"cluster.routing.allocation.node_concurrent_recoveries": 50,
"indices.recovery.max_bytes_per_sec": "2048mb",
"cluster.routing.allocation.disk.threshold_enabled" : true,
"cluster.routing.allocation.disk.watermark.low" : "70%",
while true; do curl -XGET 'cluster:9200/_cat/thread_pool?v&h=host,search.queue,search.active,search.rejected,search.completed' | sort -unk 2,3 ; sleep 5 ; done
@fdv
fdv / delete-tweets.rb
Created April 16, 2017 08:42
Delete tweets you don't want anymore
# Before running that script, use Twitter backup CSV file to pick up the tweets
# you want to delete. Save, then run:
# cat tweets.csv | cut -f 2 -d '"' | grep '^[0-9]*$' | sed '/^$/d' > delete.csv
# gem install twitter (in case you miss the gem already)
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ''
config.consumer_secret = ''
@fdv
fdv / git-commands.sh
Last active August 29, 2024 09:57
A few useful git commands
# in /usr/local/bin/git-cleanup-merged
#!/bin/sh
#!/usr/bin/env bash
current_branch=$(git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
if [ "$current_branch" != "master" ] && [ "$current_branch" != "main" ]; then
echo "WARNING: You are on branch $current_branch, NOT master or main."
fi
#!/bin/bash
SWAP_SIZE=4g
TEMP_ROOT_PASSWORD="53nD0tt3rP1c5"
# Partition table
mfiutil delete mfid0
for drive in $(mfiutil show drives | grep -v SSD | awk '{print $1}'); do
mfiutil create jbod $drive
if [ -f "${LOCK_FILE}" ]; then
log_error "A backup is already running with pid $(cat ${LOCK_FILE})"
echo $$ > "${LOCK_FILE}"
if [ $? -gt 0 ]; then
log_error "Error: could not create lock file, exiting"
fi
fi
# do all the logic here
@fdv
fdv / persistent.sh
Created December 1, 2017 15:37
Persistent settings
curl -XPUT 'http://cluster:9200/_cluster/settings?master_timeout=12000s' -d '{
"persistent" : {
"cluster.routing.allocation.disk.threshold_enabled" : true,
"cluster.routing.allocation.disk.watermark.low" : "78%",
"cluster.routing.allocation.disk.watermark.high" : "79%"
}
}'
@fdv
fdv / Install.md
Last active April 16, 2018 10:00
Dhclient6 for FreeBSD configuration

Install the package

pkg install isc-dhcp43-client

/etc/rc.conf

ipv6_enable_all_interfaces="YES"

Keybase proof

I hereby claim:

  • I am fdv on github.
  • I am fdevillamil (https://keybase.io/fdevillamil) on keybase.
  • I have a public key ASAilsSLOYy1hcdeBrJCAix4CRR4YFJpEsf46JZAkt6qLAo

To claim this, I am signing this object: