19 ms·
A small plug for my own script: I'm proud to present the most useful, least-work script I've ever written: `math` https://github.com/shawwn/scrap/blob/master/m
by sillysaurusx 5y ago
A small plug for my own script: I'm proud to present the most useful, least-work script I've ever written: `math`
https://github.com/shawwn/scrap/blob/master/math https://github.com/shawwn/scrap/blob/master/math
#!/bin/sh
scale=4 # results will print to the 4th decimal
echo "scale=$scale; $@" | bc -l
It just yeets all its arguments into bc -l, so you can run math 1+2-3 or math '(1024 - 7)*10' or whatever else you want. I even use it in other shell scripts, since bash's math facilities are rather limited and inconsistent across sh vs bash.
:~$ echo $(((3+4)*5))
35
:~$ echo $(((3+4)*5/1024))
0
:~$ math '((3+4)*5/1024)'
.0341
It has all the precision you want, as long as you only want results up to the 4th decimal.
It's surprising how much I use it. I find myself absentmindedly typing out math 220*1024*1024 while talking to people in meetings (what, you don't have meetings where it's crucial to know how quickly 220MB can be transferred?) and like thousands of other situations.
Meanwhile, funny story: I bought an iPad recently, and discovered that it's a delightful way to pass the time while shopping. You can stick it in your cart and pull up 3blue1brown and zone out while getting your pineapples. So I was doing that, and I went to reach for the calculator app to figure something out, and discovered that there is no calculator on iPads.
The punchline is that if you want a calculator on an iPad, it'll either cost you $5 or your soul: https://i.imgur.com/CJsDtB0.jpg https://i.imgur.com/CJsDtB0.jpg
Someone please make SpeedCrunch, but MsPaint. I miss MsPaint every day. There's an OS X app called Paintbrush which is similar, but unfortunately quite buggy and somehow even more limited in certain respects. Being able to just paste a screenshot and draw a red circle within 5 seconds is something that I wish we could do in 2022. Nay, I say that it's our right as programmers to be able to do that. </rallying cry>
EDIT: formatting. TIL you can backslash-escape asterisks on HN.
- namanyayg 5y agoI use Flameshot for screenshots. Onpaste (web) is good too.
- hk__2 5y ago> I miss MsPaint every day. I’m like you. On Linux there’s KolourPaint that does the job, but on macOS I never found any desktop app that does what I want. In the browser, there’s this clone [1] that mimicks all the features of the original one. You can "open" a file, "save" it, and everything in the meantime is saved in local storage. [1]: https://jspaint.app/ https://jspaint.app/
- notRobot 5y agoAlso see: https://paint.js.org/ https://paint.js.org/ https://paint.ssuiteoffice.com/#local:a29cc260bea4d https://paint.ssuiteoffice.com/#local:a29cc260bea4d https://paintz.app/ https://paintz.app/
- mulmen 5y ago> ... and discovered that there is no calculator on iPads. Wait, what!? I have never used an iPad but this just floors me. Imagine going to an Apple store, asking about the new iPad, listening to the pitch, nodding along as they play fruit ninja and draw a smiley face with a stylus and then asking "what's the 12th digit of the square root of two?". How can it not have a calculator? I mean, what? I'm old and jaded and consumer grade technology hasn't amazed me or made my life better in well over a decade but this is a whole new level.