fosstodon.org is one of the many independent Mastodon servers you can use to participate in the fediverse.
Fosstodon is an invite only Mastodon instance that is open to those who are interested in technology; particularly free & open source software. If you wish to join, contact us for an invite.

Administered by:

Server stats:

11K
active users

This is all you need to know:

~ $ top -bn1 |grep -A9999 "^ *PID " |awk '{foo+=$9} END {print foo}'
160.1
~ $ sensors |grep ^Package
Package id 0: +85.0°C (high = +100.0°C, crit = +100.0°C)
~ $ grep -m1 ^model.name /proc/cpuinfo
model name : 12th Gen Intel(R) Core(TM) i7-1260P

:eyeroll:

@RL_Dane
I have no idea what's going on. Yet, I know I could if I took the time to read the manpages and parse those flags.

I'm seriously conflicted right now.

@benjaminhollon

Teaching mode, engage!

top -bn1 |grep -A9999 "^ *PID " |awk '{foo+=$9} END {print foo}'
top: Run 1 instance of top and send it to STDOUT instead of a fancy tty-aware screen
grep: show me at least 9,999 lines after anything that matches this regexp, and the match itself
awk: use foo as a variable to accumulate the values in field 9 (cpu usage), and print it out once EOF is reached
output: 160.1

...

@RL_Dane
Yikes, your use of awk is *far* more complex than mine.

Okay I think I've got this figured out so far.

@benjaminhollon

I mean, awk is basically a complete programming language.

I've used it for two decades and still barely scratched the surface. ;)

@RL_Dane
~] man awk | wc -l
1660
~] calc "$(man awk | wc -l) - $(man tar | wc -l)"
651

That's not too bad. Perhaps I should take the time to figure it out.

@benjaminhollon

What is `calc`? Where does that come from?
I've been using bc, just because that's what I know. It's not super elegant, but it works well:

$ echo "1+1" |bc
2
$ echo "5/2" |bc
2
$ echo "5/2" |bc -l
2.50000000000000000000

@RL_Dane
I don't remember why I didn't like bc, but there was a reason. I did try it.

Here's calc: github.com/lcn2/calc

I think I liked the interactive shell you get if you don't provide any arguments. Not sure.

GitHubGitHub - lcn2/calc: C-style arbitrary precision calculatorC-style arbitrary precision calculator. Contribute to lcn2/calc development by creating an account on GitHub.
R. L. Dane :debian: :openbsd:

@benjaminhollon

Github pages are a total pain to browse with w3m.

Have you tried just using python as a math interpreter? ;)

@RL_Dane
You could just clone it and open the README in vim or less, you know.

And yes I have had python recommended to me and it works fine, but for whatever reason I abhor using python. I get shivers every time I consider it.

I guess I could use deno.

~] deno
Deno 1.31.1
exit using ctrl+d, ctrl+c, or close()
REPL is running with all permissions allowed.
To specify permissions, run `deno repl` with allow flags.
> 3 + 5
8
> 5 ** 30202
Infinity
> 0.1 + 0.2
0.30000000000000004

@RL_Dane
> [] + [0]
"0"
> [] * []
0
> [] / []
NaN

@benjaminhollon

I mean, JS has its own peculiarities like that, too.

@benjaminhollon

using JS for basic math?

*twitch* *twitch*

@RL_Dane
*That's* how I feel about using python for basic math. ;)

@benjaminhollon

I mean, I think it's a lot less odious than JS, but to each his own psychosis ;)

@RL_Dane
Oh I'd never use JS either. I'm just using it to illustrate the principle. XD

I wanted a dedicated utility, tried bc and didn't like it, tried calc and did.

@RL_Dane
Just for the record:

~] pytohn
pytohn: command not found
~] python
Python 3.10.9 (main, Dec 6 2022, 18:44:57) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1 + 0.2
0.30000000000000004

@benjaminhollon

DADGUM.

~ $ echo "0.1+0.2" |bc -l
.3
~ $ perl -e 'print 0.1+0.2,"\n"'
0.3
~ $ python -c 'print( 0.1+0.2 )'
0.30000000000000004

@RL_Dane
Let me introduce you to the most wonderful domain name ever: 0.30000000000000004.com

Floating point math is tricky, ain't it? ;)

0.30000000000000004.comFloating Point Math

@benjaminhollon

VERY cool. Both a great rant-as-URL, and very informative.