Skip to content

Instantly share code, notes, and snippets.

View shlomi-noach's full-sized avatar

Shlomi Noach shlomi-noach

View GitHub Profile
@shlomi-noach
shlomi-noach / orchestrator-demo-playbook.sh
Created May 26, 2020 17:48
Playbook to show some of orchestrator's capabilities, used in DB AMA presentation.
#!/bin/bash
# This playbook assumes you have cloned https://github.com/openark/orchestrator
# and ran: ./script/dock system
# which landed you in orchestrator's playground environment.
# Further information available on the welcome screen once you've ran the docker image.
# FYI, orchestrator's config file is at /etc/orchestrator.conf.json
orchestrator-client -c topology-tabulated -alias ci
orchestrator-client -c topology-tabulated -alias ci | tr '|' '\t'
@shlomi-noach
shlomi-noach / slack-css-override.css
Last active November 16, 2017 12:51
Slack CSS override
/*
// Override Slack CSS
// Tested with Slack 2.8.2 Direct Download
// Instructions:
// - Append the following javascript code to:
// - /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js (MacOS/X)
// - /usr/lib/slack/resources/app.asar.unpacked/src/static/ssb-interop.js (Debian/Ubuntu)
@shlomi-noach
shlomi-noach / ts-to-gnuplot.sh
Created January 12, 2016 11:52
Use tiemserias input (TS,value) as input to gnuplot
# Assuming time series is in /tmp/ts-data.dat
# Assuming timeseries in 2015-01-02 format (change according to data)
echo '
set xdata time
set timefmt "%Y-%m-%d"
set terminal dumb size 120, 24
plot "/tmp/ts-data.dat" using 1:2 title "data pr time unit" with histeps
' | gnuplot
@shlomi-noach
shlomi-noach / brew-install.bash
Last active May 30, 2016 08:19
Useful set of brew packages to install on OS/X
#!/bin/bash
# good brew setup for Mac OS/X
brew tap homebrew/dupes
brew install homebrew/dupes/grep
brew install go --with-cc-all
brew install coreutils findutils gnu-tar gnu-sed gawk gnutls gnu-indent gnu-getopt
brew install git gnupg rpm npm bash-completion
@shlomi-noach
shlomi-noach / block_mysql_access.bash
Created November 15, 2015 09:31
Block/unblock MySQL 3306 access via iptables
#!/bin/bash
#
# Usage: block_mysql_access.bash [true|false]
# "true" or empty input blocks 3306 access, via iptables
# "false" re-enables access to 3306
#
if [ $# -eq 0 ] || [ "$1" == "true" ]; then
sudo -i /sbin/iptables -I INPUT -p tcp --destination-port 3306 -j REJECT
elif [ "$1" == "false" ]; then
@shlomi-noach
shlomi-noach / mysql-table-size-ondisk.sh
Last active October 19, 2015 11:43
Bash script to calculate MySQL table dimensions on disk
#!/bin/bash
(
mysql_datadir=$(grep datadir /etc/my.cnf | head -n 1 | cut -d "=" -f 2 | cut -d "#" -f 1)
cd $mysql_datadir
for frm_file in $(find . -name "*.frm" | egrep -v "[.]/(mysql|sys|performance_schema|common_schema)")
do
table_schema=$(echo $frm_file | cut -d "/" -f 2)
table_name=$(echo $frm_file | cut -d "/" -f 3 | cut -d "." -f 1)
if [ -f ${frm_file//.frm/.MYD} ]; then
@shlomi-noach
shlomi-noach / binlog-rbr-to-sbr.py
Last active November 26, 2019 19:59
binlog-rbr-to-sbr
#!/usr/bin/python
#
# Convert a Row-Based-Replication binary log to Statement-Based-Replication format, cheating a little.
# This script exists since Percona Toolkit's pt-query-digest cannot digest RBR format. The script
# generates enough for it to work with.
# Expecting standard input
# Expected input is the output of "mysqlbinlog --verbose --base64-output=DECODE-ROWS <binlog_file_name>"
# For example:
# $ mysqlbinlog --verbose --base64-output=DECODE-ROWS mysql-bin.000006 | python binlog-rbr-to-sbr.py | pt-query-digest --type=binlog --order-by Query_time:cnt --group-by fingerprint
#