Skip to content

Instantly share code, notes, and snippets.

@tonkatsu7
tonkatsu7 / abortMergeUndoFetchRenamebranch.sh
Last active June 26, 2021 14:14
Remediating diverged branch by abort merge undoing fetched changes and renaming local branch
# abort merge with diverged remote branch
git merge --abort
# https://stackoverflow.com/questions/6591213/how-do-i-rename-a-local-git-branch
# rename local branch
git branch -m tutorial
# https://stackoverflow.com/questions/35591887/how-to-undo-git-fetch
# discard fetched changes
git remote remove origin
@tonkatsu7
tonkatsu7 / fixDquoteOnZsh.sh
Created June 13, 2021 02:45
Reverting zsh prompt when quote appears due to non terminating string
# https://stackoverflow.com/questions/15773278/dquote-result-of-a-execution-a-program-in-linux-shell
"
@tonkatsu7
tonkatsu7 / visualisingGitBranches.sh
Last active May 25, 2021 23:00
Visualising git branches on the command line
git log --graph --decorate --oneline
git log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
git config --global alias.lg "log --all --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@tonkatsu7
tonkatsu7 / installZookeeperOnUbuntu.sh
Created November 8, 2020 07:36
Install and start zookeeper on Ubuntu 20.04
sudo apt install zookeeperd
sudo service zookeeper start
sudo service zookeeper status
# https://linuxconfig.org/how-to-install-and-configure-zookeeper-in-ubuntu-18-04
# https://stackoverflow.com/questions/29016986/best-way-to-start-zookeeper-automatically-on-ubuntu-server-14-04
@tonkatsu7
tonkatsu7 / mySqlLoadDataInfileCRLF.sql
Last active November 8, 2020 00:24
How MySQL 5.7 Handles 'utf8mb4' and the Load Data Infile lines terminated with CRLF
set global local_infile=1;
quit
# sh
sudo mysql --local-infile=1 -u root
# https://dzone.com/articles/mysql-57-utf8mb4-and-the-load-data-infile
# https://www.percona.com/blog/2016/07/05/mysql-5-7-utf8mb4-and-the-load-data-infile/
# https://stackoverflow.com/questions/14127529/mysql-import-data-from-csv-using-load-data-infile
@tonkatsu7
tonkatsu7 / installMySQLOnUbuntu.sh
Created November 7, 2020 05:06
Install MySQL on Ubuntu 20.04 LTS
# install mysql server
sudo apt-get install mysql-server
# start mysql server
sudo /etc/init.d/mysql start
# log into mysql server
sudo mysql -u root
@tonkatsu7
tonkatsu7 / esBasicAuth.py
Created November 1, 2020 06:22
Connect to elasticsearch 7 using basic authentication in Python
host = 'SOME_GUID.southeastasia.azure.elastic-cloud.com' #without 'https'
basicAuth = ('USERNAME', 'PASSWORD')
es = elasticsearch.Elasticsearch(
hosts=[{'host': host, 'port': 9243}],
http_auth=basicAuth,
use_ssl=True,
verify_certs=True,
connection_class=elasticsearch.RequestsHttpConnection
)
@tonkatsu7
tonkatsu7 / standupIoTEdgeDev.cmd
Last active June 2, 2019 10:22
Stand up Azure IoT Edge dev 4 Linux containers environment
# Open a PowerShell console as Administrator
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
# Restart Windows
# Open a cmd as administrator
# Install choco
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
@tonkatsu7
tonkatsu7 / az-acli.cmd
Created June 2, 2019 06:02
Azure cli commands
az account list
az account set --subscription {guid}