Check These Out
Sort a list of IPV4 addresses in numerical order. Great as a filter, or within vim using !}
record audio notes or meetings
requires arecord and lame
run mp3gain on the resulting file to increase the volume / quality
ctrl-c to stop recording
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"
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"
}
ZSH ships a couple random number generators via the $RANDOM environment variable and rand48() via zsh/mathfunc, but neither are cryptographically secure. This code produces a 32-bit random number suitable for cryptography. It's only dependency is /dev/urandom and it does not rely on any shell commands or 3rd party utilities. It assumes ZSH was compiled with 64-bit integer support.
Useful when you're trying to unmount a volume and other sticky situations where a rogue process is annoying the hell out of you.
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"
}
I like to label my grub boot options with the correct kernel version/build.
After building and installing a new kernel with "make install" I had to edit my grub.conf by hand.
To avoid this, I've decided to write this little command line to:
1. read the version/build part of the filename to which the kernel symlinks point
2. replace the first label lines of grub.conf
grub.conf label lines must be in this format:
Latest [{name}-{version/build}]
Old [{name}-{version/build}]
only the {version/build} part is substituted.
For instance:
title Latest [GNU/Linux-2.6.31-gentoo-r10.201003]
would turn to
title Latest [GNU/Linux-2.6.32-gentoo-r7.201004]"