This post is for me a place where to store notes about Docker. I hope that this can be helpful for you.
L'AmministraTuri
My personal-tech blog
20/05/20
25/06/19
Vim Quick Reference
Basically, vim has three working modes:
- Command mode
- Insert Mode
- Ex-mode
Basic VIM Movement
- b move back from word
- w move next to word
Commands
Disable text wrap
:set wrap!(you can use ~/.vimrc)
Display or hide line numbers?
:set numberfor display
:set nonumberfor hide
29/04/19
VMWARE - Get snapshots and size of VMs
Today I need to check the snapshots of all VMs of a VMware infrstructure. Unfortunately I have found that with vSphere Client and vSphere Web Client it's not possibile to get a list of snaps associated to VMs.
So, after a advanced google search, I have found that this is possibile using VMware PowerCLI tools.
I've installed the version 5.5 available in this page https://code.vmware.com/web/tool/5.5/vmware-powercli
After this, I use powershell for loading the snapin and connect to my vcenter server with this:
add-pssnapin vmware.vimautomation.core
connect-viserver myvcentersrv_FQDN
Then with the commmand I get the list with VM name, number of snapshot and size:
Get-VM | Format-Table Name, @{Label="NumSnapshots";Expression={(Get-Snapshot -VM $_ | Measure-Object).Count}}, @{Label="TotalSnapShotSizeMB";Expression={(Get-Snapshot -VM $_ | Measure-Object -Sum SizeMB).Sum}}
Ref: http://www.vhersey.com/2016/03/01/quick-powercli-to-get-snapshots-and-size/
04/12/18
Pip Quick Reference
Basic pip usage
- Upgrade PIP
python -m pip install --upgrade pip
- Find outdated/updatable pip packages
pip list --outdated
08/09/18
Git Hooks - A way to automate deploy tasks
During my work I use git for automate the deploy on production system. Sometimes I need execute some command or script immediately after checkout. Git has a very powerful mechanism called hooks (you can read more about it on official documentation follow this link).
On client side to install hooks what you have to do is to create a dir called hooks under .git/ . But you do not have to do any of this because when you have initialized your project git create it for you.
If you list the content of hooks dir you can found a list of samples script to use (all of them are bash scripts). Most of this script start with the prefix pre- or post- followed by action name.
The script that I found helpful is post-checkout that is automatically executed after a successful git checkout. My post-checkout script contain commands for adjust permissions on files and ask to restart web server.
On client side to install hooks what you have to do is to create a dir called hooks under .git/ . But you do not have to do any of this because when you have initialized your project git create it for you.
If you list the content of hooks dir you can found a list of samples script to use (all of them are bash scripts). Most of this script start with the prefix pre- or post- followed by action name.
The script that I found helpful is post-checkout that is automatically executed after a successful git checkout. My post-checkout script contain commands for adjust permissions on files and ask to restart web server.
#!/bin/bash
git ls-files -z --with-tree="$2" --directory | xargs -0 chmod o-rxw --
git ls-files -z --with-tree="$2" --directory | xargs -0 chown www-data:www-data --
find . -type d | xargs -I {} chown www-data:www-data {}
find . -type d | xargs -I {} chmod o-rwx {}
exec < /dev/tty
while true;
do
read -p "Do you want to restart apache? [Y/N]:" choice
case "$choice" in
y|Y) service apache2 restart;break;;
n|N) break;;
*) echo "invalid" && break;;
esac
done
Remember to add execute permission to this script or git won't execute it after the checkout.
16/03/18
Git Handbook
How to setup git with SSH Key
# git remote set-url origin [email protected]:<Username>/<Project>.git
Windows CRLF chars.
Su windows bisogna disattivare questa funziona altrimenti non funzionano i caratteri CRLF.# git config core.autocrlf false
How can I debug git/git-shell related problems?
If you have problem with Git and you need to debug you can run this:# GIT_CURL_VERBOSE=1 GIT_TRACE=1 git pullRef: https://stackoverflow.com/questions/6178401/how-can-i-debug-git-git-shell-related-problems
How to get list of files between change log ?
If you need to get list of files (included directory tree) from change list you can use:# git diff-tree -r --name-only 2c636a^ 5b47402 | xargs -I {} rsync -aR {} output/
Delete files from git index when they are already deleted
# git ls-files --deleted -z | xargs -0 git rm
How do I show my global git config?
# git config --list
Show remote branches
# git branch -vr
Filename too long in git for windows
git config --system core.longpaths trueNote: You need to run as administrator.
Ref: https://stackoverflow.com/questions/22575662/filename-too-long-in-git-for-windows
List log with tag date
git log --date-order --graph --tags --simplify-by-decoration --pretty=format:'%ai %h %d'
Configure username and mail
# git config --global user.name "Name Surname" # git config --global user.email "mymail(at)mydomain.com"
02/03/18
How to improve reading of log files
There are hard times when a sysadmin have to read a lot of rows of log files for troubleshoot a system error. In this times can be helpful to use some tools to improve reading of these files.
I've found two tools:
I've found two tools:
- Generic Colouriser (GRC) - https://github.com/garabik/grc - there are programs: grc and grcat. The main is grcat, which acts as a filter, i.e. taking standard input, colourising it and writing to standard output. Then you can use configuration files for customize color ouput depend on you application output log.
- Log File Navigator (LNAV) - http://lnav.org/ - this is a real log file navigator that parse content of file and follow the stream for read latest lines. Lnav can help highlight the parts that are important and filter out the noise.
19/01/18
How to launch python Idle from a virtual environment (virtualenv)
If you have a virtual environment and you want to use IDLE for write you pretty script you can run this command:
# python -m idlelib.idle
Ref: https://stackoverflow.com/questions/8792044/how-do-i-launch-idle-the-development-environment-for-python-on-mac-os-10-7/8792082#8792082
29/08/17
How to view all ssl certificates in a bundle?
This morning I got a problem with a certificate bundle and how to get single certificate inside it.
I found the answer on ServerFault (link).
I found the answer on ServerFault (link).
# openssl crl2pkcs7 -nocrl -certfile bundle.crt | openssl pkcs7 -print_certs -text -noout
06/03/17
Sed Quick Reference
Basic sed usage
- Add "-dev" at the end of the match.
# sed -i 's|saml[1-2]-.*\.php/[a-zA-Z0-9\-]*|&-dev|
Iscriviti a:
Post
(
Atom
)