Tipping like it's 1989 (or: emacs iPhone
Tipping like it's 1989 (or: emacs iPhone <3) • Super Pork Chop

  

  
  

  
  Long ago in the 1980’s, the geeks of yore wielded RPN calculators such as the HP-42S at the local diner. Calculating tips since has never been so cool.
But what is RPN? RPN stands for “Reverse Polish Notation", a syntax where operands are given before the operator. This is somewhat backwards compared to infix notation, which normal humans are used to, as well as prefix (aka “Polish”) notation, which is used in Lisp and other languages. Some examples:
# prefix notation (Lisp)
(+ 2 4)
# infix notation (humans)
2 + 4
# reverse polish notation (Forth)
2 4 +
Who would do such a terrible thing? Surprisingly, there are some tangible benefits to RPN. Arithmetic expressions in RPN don’t need parentheses, leading to faster input due to fewer keystrokes. Various studies also show RPN calculator users routinely beat out their infix-using counterparts in speed tests.
Nowadays, traces of RPN are hard to find. They exist only in HP-42 emulators and in song, and occasionally when Yoda has something to say in the latest Star Wars movie.
But weep no longer friends, for RPN calculations are back on the iPhone with everyone’s favorite editor, emacs!
Emacs on the iPhone
iOS has a shiny new shell called iSH which is essentially a 32-bit emulator for Alpine Linux. Since it is still in beta, it may be installed using Apple’s TestFlight app (used for beta testing apps).
Install it with the following steps:

Install TestFlight on your iPhone using the AppStore.
Open up https://ish.app/ in your iPhone’s browser.
Scroll down and tap the TestFlight icon to accept the invite for the beta iSH app and install it.

The next order of business is getting emacs - it has a suprisingly advanced RPN calculator called calc. Run the following in the iSH shell to install emacs:
Next, download an sh script by kqr that launches emacs calc from the command line, make it executable, and move it to /usr/bin so it can be executed from anywhere:
wget https://gist.github.com/dp12/4b89bb8cc89c35cbf3e599bded732afe/raw/ab482a8b8b82e08630449689862b03aa5d08bae4/emacscalc.sh
chmod u+x emacscalc.sh
mv emacscalc.sh /usr/bin/ec
Voila! You now can launch emacscalc by running ec. Now how about calculating that tip?
Since emacs calc is an RPN calculator, you first need to push the operands on the stack, and then complete the computation by entering the operator. So to calculate a run-of-the-mill 18% tip on $8.35, we’d enter the following:
8.35 RET 1.18 RET *
Here are a few other basic commands that can be useful:

U to undo
D to redo
C-g to cancel
d f 9 to display 9 digits in fixed-point format
d n to display digits in normal format
q to quit emacscalc

There is also the full gamut of commands for stack manipulation:

RET to duplicate elements on the stack
BSPC to drop elements from the stack
TAB to swap elements on the stack
M-x calc-roll-up to rotate elements on the stack (swap 1st and 3rd elements)
NOTE: Input M-x by pressing the ESC key, followed by x

Now you can impress your friends with your backward calculations and give those iVim users something to think about.
BONUS: Reddit and Reverse Engineering
radare2 is a fun reverse engineering framework with powerful features and a vertical learning curve. Surprisingly, you can get it on your iPhone as well. Just run:
It segfaults on executables of any real size, but try something smaller and you’re off to the races!
But wait, there’s more!
For command-line fans of every stripe, there’s a highly functional reddit
browser called rtv. So functional, in fact, that I prefer using it instead of my browser.
Install rtv with:
apk add py-pip
pip install rtv
To view certain subreddits, either one or multiple, you can use the -s option.
rtv -s emacs+cpp+python+programming
# Add the above as an alias
echo "alias rtvs='rtv -s emacs+cpp+python+programming'" >> ~/.profile
It scratches my inner gui luddite.




  



