Skip to content

Instantly share code, notes, and snippets.

View lichti's full-sized avatar
👨‍💻
🏊🏻🚴🏻🏃🏻

Gustavo Lichti lichti

👨‍💻
🏊🏻🚴🏻🏃🏻
View GitHub Profile
@lichti
lichti / restore-slave-dump.sh
Created November 19, 2015 03:21
Script to restore dump in MySQL Slave Server
#!/bin/bash
DUMP=${1}
DBUSER=${2}
DBPASS=${3}
DBADDR=${4:-localhost}
DBPORT=${5:-3306}
[email protected]
SLAVE_STRING=$(zcat $DUMP | head -30 | grep MASTER_LOG_FILE | sed s/--\ //g)
Atenção: Leia todo o artigo antes de realizar quaisquer mudanças e por favor, FAÇA backup! Não me responsabilizo por perda de dados, eu deixo bem claro o que pode ou não acarretar risco em perda de dados. Por favor, se algo estiver errado me avise!
Data da Publicação: 06/04/2012 - Editado em 07/11/2012 - Nova edição em 18/03/2015 na sessão "Considerações Gerais"!
1) Introdução
Esse artigo não é bem um tutorial, talvez mais propriamente um relato com algumas dicas de minha experiência com ele nos últimos meses em alguns PCs e alguns Notebooks de usuários comuns. Nesses últimos meses venho utilizando o XFS em minhas máquinas pessoais e no trabalho. Como ele não é o sistema de arquivos padrão de nenhuma distro que eu conheça, o pessoal acaba não fazendo muito uso dele no desktop. Este artigo está longe de mostrar tudo o que o XFS é capaz de fazer, visei apenas a situação mais usual, um usuário comum com apenas um HD.
O XFS foi criado e pensando para ser grande. Ele é um sistema de arquivos 64bits nativo c
MYSQL_CONN="-uroot -ppassword"
mysql ${MYSQL_CONN} --skip-column-names -A -e"SELECT CONCAT('SHOW GRANTS FOR ''',user,'''@''',host,''';') FROM mysql.user WHERE user<>''" | mysql ${MYSQL_CONN} --skip-column-names -A | sed 's/$/;/g' > MySQLUserGrants.sql
mysql -uroot -p -A < MySQLUserGrants.sql
@lichti
lichti / ssh-tunel.txt
Last active November 19, 2015 06:21
SSH Tunel
ssh -fN -L PORT:HOST:PORT user@host
ssh -fN -R PORT:HOST:PORT user@host
#!/bin/bash
function skip {
MYSQL_CONN="-uUSER -pPASS";
mysql ${MYSQL_CONN} -e "show slave status \G" | \
grep Seconds_Behind_Master | \
grep NULL && mysql ${MYSQL_CONN} -e "STOP SLAVE; \
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; \
#!/bin/bash
MYSQL_CONN="-uUSER -pPASS";
USERS="'user1','user2','usern'"
mysql ${MYSQL_CONN} -e "select concat('KILL ',id,';') from information_schema.processlist
where user IN (${USERS}) \
into outfile '/tmp/sleep_processes.txt'; \
source /tmp/sleep_processes.txt;"; \
rm -rf /tmp/sleep_processes.txt
@lichti
lichti / recovery-dd.txt
Created November 20, 2015 16:42
Recover data after running “dd if=/dev/zero …” for a few seconds
https://devjlanza.wordpress.com/2012/05/11/recover-data-after-running-dd-ifdevzero-for-a-few-seconds/
Friday morning working on installing OpenWrt pivot overlay on an USB pendrive. I need to format the USB and as I was doing it quite so many times I wasn’t paying too much attention. Don’t do that at home ;)
The USB was recognized as /dev/sdb1 on my laptop but on the router it was on /dev/sda1. As you have probably already guessed my main laptop hardrive was /dev/sda1.
I didn’t notice I wasn’t in the router console (f….. tabs) and after having successfully formatted the USB I decided to make it zero:
# dd if=/dev/zero of=/dev/sda1
I continue working on the laptop but when in typed ‘ls’ nothing is shown and even I got unknown command. Uppps… something is going wrong. I just realized I was formatting my hard drive in stead of the USB.
@lichti
lichti / tmux.md
Created November 24, 2015 18:44 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

#!/bin/bash
while true
do
wmctrl -l | awk '{print $1}' > /tmp/windows.txt
while read win
do
echo $win
#wmctrl -i -R $win -b add,fullscreen
wmctrl -i -R $win -b add,maximized_vert,maximized_horz
https://extensions.gnome.org/extension/15/alternatetab/
https://extensions.gnome.org/extension/6/applications-menu/
https://extensions.gnome.org/extension/779/clipboard-indicator/
https://extensions.gnome.org/extension/442/drop-down-terminal/
https://extensions.gnome.org/extension/683/imgur-screenshot-uploader/
https://extensions.gnome.org/extension/8/places-status-indicator/
https://extensions.gnome.org/extension/7/removable-drive-menu/
https://extensions.gnome.org/extension/906/sound-output-device-chooser/
https://extensions.gnome.org/extension/59/status-title-bar/
https://extensions.gnome.org/extension/593/text-translator/