Skip to content

Instantly share code, notes, and snippets.

View laszlomiklosik's full-sized avatar

Laszlo Miklosik laszlomiklosik

View GitHub Profile
@laszlomiklosik
laszlomiklosik / mysql dump and restore database from command line
Created February 20, 2014 13:58
mysql dump and restore database from command line
#1. dump
mysqldump -u root db_name > dump_name.sql
#2. restore
mysql -u root -p db_name < dump_name.sql
@laszlomiklosik
laszlomiklosik / mysql case sensitivity disabling
Created March 21, 2014 08:25
mysql case sensitivity disabling
# if you want queries executed in all you schemas to be case insensitive do this
$ sudo gedit /etc/mysql/my.cnf
edit the file adding the entry lower_case_table_names=1 just under the group definition: [mysqld]
[mysqld]
lower_case_table_names=1
@laszlomiklosik
laszlomiklosik / Create heap dump on the fly using jmap
Created March 24, 2014 12:26
Create heap dump on the fly using jmap
# jmap is in $JAVA_HOME/bin/ (assumed in your path, but you can use the complete path if it's not)
jmap -dump:format=b,file=heap_dump.hprof <process ID>
@laszlomiklosik
laszlomiklosik / Push a new changeset to Gerrit
Last active August 29, 2015 14:02
Push a new changeset to Gerrit
# 1. First make sure you copied the Gerrit commit-msg hook (from Gerrit to your local repos .git/hooks folder)
# 2. Make the code changes needed and then stage them using the usual command
git add . -A
# 3. Now commit them using amend and notice that the previous commit message is used but is suffixed with the Change-Id of your previous commit. Make sure you leave that (even if you modify the commit message). Note: modifying the commit message will overwrite the previous one.
git commit --amend
# 4. push your changes for review:
git push origin HEAD:refs/for/master
@laszlomiklosik
laszlomiklosik / Search file by contained text (Linux command)
Created June 23, 2014 11:45
Search file by contained text (Linux command)
# find all XML files from current directory (including its subdirectories recursively) by content 'sonar'
find . -name '*.xml' -print0 | xargs -0 grep 'sonar'
@laszlomiklosik
laszlomiklosik / Mark all *.sh files executable in all subdirectories
Created October 9, 2014 08:05
Mark all *.sh files executable in all subdirectories
find . -iname \*.sh | xargs chmod +x
@laszlomiklosik
laszlomiklosik / Cropping the relevant section from a log file
Created December 17, 2014 12:40
Cropping the relevant section from a log file
# 1) get line number of first relevant log line: (e.g. by date 2014-01-13 13:49)
grep "2014-01-13 13:49" original.log -n | more
# 2) get line number of last relevant log line: (e.g. by date 2014-01-13 16:36)
grep "2014-01-13 16:36" original.log -n | more
# 3) the total number of lines from the original log file:
wc -l original.log -n
# e.g. results of 1-3:
@laszlomiklosik
laszlomiklosik / Apache2 Basic Authentication config example
Created March 31, 2015 17:07
Apache2 Basic Authentication config example
# Add the below in the VirtualHost section (in apache2.conf of the sites-enabled/* file):
<Location />
Deny from all
AuthUserFile /usr/local/etc/httpd/users
AuthName authorization
AuthType Basic
Satisfy Any
require valid-user
</Location>
@laszlomiklosik
laszlomiklosik / Start Python web server to serve current directory
Created April 2, 2015 12:42
Start Python web server to serve current directory
python -m SimpleHTTPServer
@laszlomiklosik
laszlomiklosik / Docker behind a company HTTP proxy.md
Last active August 29, 2015 14:18
Docker behind a company HTTP proxy

In order to be able to download images from the internet,

  • add the below lines:

    export http_proxy=http://proxy:8080

    export https_proxy=http://proxy:8080

    export no_proxy=*.lan