CPU Usage Percent – Python One-Liner for Load Average per CPU

Processor usage is 88%. But how do I get a number like this? For gurus, this Python one-liner prints CPU usage $ python3 -c “print(‘{:.0f}%’.format( float(‘$(cat /proc/loadavg)’.split()[0]) / float(‘$(nproc)’)*100 ) )” 12% The rest of us can read on how … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , | Comments Off on CPU Usage Percent – Python One-Liner for Load Average per CPU

Print Special Characters as Backslash Escapes – Python3 One-liner with Unicode Support

Let’s find that weird or invisible character that breaks your code $ echo “Hello in Finnish: Päivää”|python3 -c ‘import sys; s=sys.stdin.read(); print(s.encode(“unicode_escape”));’ b’Hello in Finnish: P\\xe4iv\\xe4\\xe4\\n’

Posted in Uncategorized | Tagged , , , , , , , , , , , , | Comments Off on Print Special Characters as Backslash Escapes – Python3 One-liner with Unicode Support

Python RegEx One-Liner in a Pipe – Remove Hard Line Wrapping – No Perl

Just put Python in your pipe and let Perl rest in peace. Python can be used as a one-liner in a pipe. Replacing text with a regular expression used to be the last holdout of perl, but now you can … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , | Comments Off on Python RegEx One-Liner in a Pipe – Remove Hard Line Wrapping – No Perl

Hello Puppet revisited – on Ubuntu 12.04 LTS

Learn “Hello Puppet World” in 5 minutes. Write one-liners & modules. Meet the configuration management system used by Google and Wikipedia.

Posted in Uncategorized | Tagged , , , , , , , , , , | Comments Off on Hello Puppet revisited – on Ubuntu 12.04 LTS