Check These Out
If colordiff utility installed, it is sometimes handy to call this command. Of course, you should create an alias for it. E.g. svndiff.
In this way it doesn't have problems with filenames with spaces.
With a couple of little commands, you?ll be able to ignore the .DS_Store files forever from your git repositories on mac!
The following command will add the .gitignore file to the git configuration
git config --global core.excludesfile ~/.gitignore
then, the following, will add the .DS_Store to the list
echo .DS_Store >> ~/.gitignore
Converts any number of seconds into days, hours, minutes and seconds.
sec2dhms() {
declare -i SS="$1"
D=$(( SS / 86400 ))
H=$(( SS % 86400 / 3600 ))
M=$(( SS % 3600 / 60 ))
S=$(( SS % 60 ))
[ "$D" -gt 0 ] && echo -n "${D}:"
[ "$H" -gt 0 ] && printf "%02g:" "$H"
printf "%02g:%02g\n" "$M" "$S"
}
QR codes are those funny square 2d bar codes that everyone seems to be pointing their smart phones at.
Try the following...
$ qrurl http://xkcd.com
Then open qr.*.png in your favorite image viewer.
Point your the bar code reader on your smart phone at the code, and you'll shortly be reading xkcd on your phone.
URLs are not the only thing that can be encoded by QR codes... short texts (to around 2K) can be encoded this way, although this function doesn't do any URL encoding, so unless you want to do that by hand it won't be useful for that.
This is useful for example if you are on ssh in a server and the server goes down without letting you out.
This is part of a larget sets of escape sequences provided by ssh. You can find them with ~? Here's the list:
~. - terminate connection (and any multiplexed sessions)
~B - send a BREAK to the remote system
~C - open a command line
~R - request rekey
~V/v - decrease/increase verbosity (LogLevel)
~^Z - suspend ssh
~# - list forwarded connections
~& - background ssh (when waiting for connections to terminate)
~? - this message
~~ - send the escape character by typing it twice
(Note that escapes are only recognized immediately after newline.)
You might want to secure your AWS operations requiring to use a MFA token. But then to use API or tools, you need to pass credentials generated with a MFA token.
This commands asks you for the MFA code and retrieves these credentials using AWS Cli. To print the exports, you can use:
`awk '{ print "export AWS_ACCESS_KEY_ID=\"" $1 "\"\n" "export AWS_SECRET_ACCESS_KEY=\"" $2 "\"\n" "export AWS_SESSION_TOKEN=\"" $3 "\"" }'`
You must adapt the command line to include:
* $MFA_IDis ARN of the virtual MFA or serial number of the physical one
* TTL for the credentials
Shows all block devices in a tree with descruptions of what they are.