Thursday, September 27, 2018

Monday, September 24, 2018

Dumping and importing from/to MySQL in an UTF-8 safe way

Dumping safely

# Do not do this, since it might screw up encoding
mysqldump -uroot -p database > utf8.dump # this is bad
Better do:
mysqldump -uroot -p database -r utf8.dump
Note that when your MySQL server is not set to UTF-8 you need to do mysqldump --default-character-set=latin1 (!) to get a correctly encoded dump. In that case you will also need to remove the SET NAMES='latin1' comment at the top of the dump, so the target machine won't change its UTF-8 charset when sourcing.
If you only want to dump the structure without data, use
mysqldump -uroot -p --no-data database -r utf8.dump

Importing a dump safely

# Do not do this, since it might screw up encoding
mysql -u username -p database < dump_file # this is bad
Better do:
mysql -uroot -p --default-character-set=utf8 database
mysql> SET names 'utf8'
mysql> SOURCE utf8.dump
https://makandracards.com/makandra

Saturday, September 22, 2018

Postman alternative

Free
Faster
No electron
https://github.com/RohitAwate/Everest

Java 8 for ubuntu18.04, Java SE 8 (LTS), Extended Support Until March 2025

sudo apt-get install oracle-java8-installer
sudo apt-get install oracle-java8-set-default
sudo update-alternatives --config java
sudo update-alternatives --config java
java -version
javac -version
At the end of this file, add the following line, making sure to replace the highlighted path with your own copied path:
sudo vim /etc/environment
JAVA_HOME="/usr/lib/jvm/java-8-oracle/jre/bin/java/"
echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle/jre/bin/java/

Thursday, September 20, 2018

Kill ssh sessions

ps -ef | grep sshd | grep -v root | grep -v 12345 | grep -v grep | awk '{print "sudo kill -9", $2}' |sh

Thursday, September 13, 2018

Search in gz and plain files recursively

reset;\
find -name \*.log -print0 | xargs -0 grep "delete from"; \
find -name \*.gz -print0 | xargs -0 zgrep "delete from";

How to revert comments Youtube layout?

#see video for details  https://www.youtube.com/watch?v=J0L_nYtNlqs #uBlock Origin  https://chrome.google.com/webstore/detail/ublock-o...