Qalculate hacks - anarcat
This is going to be a controversial statement because some people are<br>absolute nerds about this, but, I need to say it.
Qalculate is the best calculator that has ever been made.
I am not going to try to convince you of this, I just wanted to put<br>out my bias out there before writing down those notes. I am a total<br>fan.
This page will collect my notes of cool hacks I do with<br>Qalculate. Most examples are copy-pasted from the command-line<br>interface (qalc(1)), but I typically use the graphical interface as<br>it's slightly better at displaying complex formulas. Discoverability<br>is obviously also better for the cornucopia of features this fantastic<br>application ships.
Qalculate hacks
Qalc commandline primer
Bandwidth estimates
Password entropy
Exchange rates
Other conversions
Completion time estimates
Background
Extracting a process start time
Saving a variable
Estimating data size
Digression over bytes
Solving a cross-multiplication
Now and built-in variables
Computing dates
Other functionality
Gotchas
Decimals precision
Fractional displays
Further reading and installation
Updates
Qalc commandline primer
On Debian, Qalculate's CLI interface can be installed with:
apt install qalc
Then you start it with the qalc command, and end up on a prompt:
anarcat@angela:~$ qalc
Then it's a normal calculator:
anarcat@angela:~$ qalc<br>> 1+1
1 + 1 = 2
> 1/7
1 / 7 ≈ 0.1429
> pi
pi ≈ 3.142
There's a bunch of variables to control display, approximation, and so<br>on:
> set precision 6<br>> 1/7
1 / 7 ≈ 0.142857<br>> set precision 20<br>> pi
pi ≈ 3.1415926535897932385
When I need more, I typically browse around the menus. One big issue I<br>have with Qalculate is there are a lot of menus and features. I had<br>to fiddle quite a bit to figure out that set precision command<br>above. I might add more examples here as I find them.
Bandwidth estimates
I often use the data units to estimate bandwidths. For example, here's<br>what 1 megabit per second is over a month ("about 300 GiB"):
> 1 megabit/s * 30 day to gibibyte
(1 megabit/second) × (30 days) ≈ 301.7 GiB
Or, "how long will it take to download X", in this case, 1GiB over a<br>100 mbps link:
> 1GiB/(100 megabit/s)
(1 gibibyte) / (100 megabits/second) ≈ 1 min + 25.90 s
Password entropy
To calculate how much entropy (in bits) a given password structure,<br>you count the number of possibilities in each entry (say, [a-z] is<br>26 possibilities, "one word in a 8k dictionary" is 8000), extract the<br>base-2 logarithm, multiplied by the number of entries.
For example, an alphabetic 14-character password is:
> log2(26*2)*14
log₂(26 × 2) × 14 ≈ 79.81
... 80 bits of entropy. To get the equivalent in a Diceware<br>password with a 8000 word dictionary, you would need:
> log2(8k)*x = 80
(log₂(8 × 000) × x) = 80 ≈
x ≈ 6.170
... about 6 words, which gives you:
> log2(8k)*6
log₂(8 × 1000) × 6 ≈ 77.79
78 bits of entropy.
Exchange rates
You can convert between currencies!
> 1 EUR to USD
1 EUR ≈ 1.038 USD
Even fake ones!
> 1 BTC to USD
1 BTC ≈ 96712 USD
This relies on a database pulled form the internet (typically the<br>central european bank rates, see the source). It will prompt<br>you if it's too old:
It has been 256 days since the exchange rates last were updated.<br>Do you wish to update the exchange rates now? y
As a reader pointed out, you can set the refresh rate for<br>currencies, as some countries will require way more frequent<br>exchange rates.
The graphical version has a little graphical indicator that, when you<br>mouse over, tells you where the rate comes from.
Other conversions
Here are other neat conversions extracted from my history
> teaspoon to ml
teaspoon = 5 mL
> tablespoon to ml
tablespoon = 15 mL
> 1 cup to ml
1 cup ≈ 236.6 mL
> 6 L/100km to mpg
(6 liters) / (100 kilometers) ≈ 39.20 mpg
> 100 kph to mph
100 kph ≈ 62.14 mph
> (108km - 72km) / 110km/h
((108 kilometers) − (72 kilometers)) / (110 kilometers/hour) ≈<br>19 min + 38.18 s
Completion time estimates
This is a more involved example I often do.
Background
Say you have started a long running copy job and you don't have the<br>luxury of having a pipe you can insert pv(1) into to get a nice<br>progress bar. For example, rsync or cp -R can have that problem<br>(but not tar!).
(Yes, you can use --info=progress2 in rsync, but that estimate is<br>incremental and therefore inaccurate unless you disable the<br>incremental mode with --no-inc-recursive, but then you pay a huge<br>up-front wait cost while the entire directory gets crawled.)
Extracting a process start time
First step is to gather data. Find the process start time. If you were<br>unfortunate enough to forget to run date --iso-8601=seconds before<br>starting, you can get a similar timestamp with stat(1) on the<br>process tree in /proc with:
$ stat /proc/11232<br>File: /proc/11232<br>Size: 0 Blocks: 0 IO Block: 1024 directory<br>Device: 0,21 Inode: 57021 Links: 9<br>Access: (0555/dr-xr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)<br>Access: 2025-02-07...