Skip to content

Instantly share code, notes, and snippets.

View laszlomiklosik's full-sized avatar

Laszlo Miklosik laszlomiklosik

View GitHub Profile
@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

@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 / 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 / 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 / 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 / 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 / Linux see how long a process has been running - uptime
Last active March 1, 2017 09:12
Linux see how long a process has been running - uptime
# Example command for checking how long a Java process was running (etime = elapsed time)
ps -eo pid,comm,cmd,start,etime | grep java
# It will return something like:
# 21443 java /opt/jdk8/bin/java -Djava.u Feb 25 3-12:46:12
# and this means an uptime of 3 Days, 12 Hours, 46 Minutes and 12 Seconds
# More alternatives & explanations here: http://linuxcommando.blogspot.ro/2008/09/how-to-get-process-start-date-and-time.html
@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 / Linux monitor the number of connections on a given port
Last active February 23, 2018 08:13
Linux monitor the number of connections on a given port
# below example is a shell script which logs the number of connections every 30 seconds
#!/bin/bash
if [ "$#" -ne 1 ]; then
echo "Please provide the port number for which you want to monitor the connection count as the one and only argument!"
exit
fi
while true; do
crtDate=`date`
@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>