Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS Publishing Workflow with Git, Snapas-hosted images, to the Writeas/WriteFreely CMS #128

Open
extratone opened this issue May 6, 2021 · 8 comments
Assignees
Labels
dev Development! documentation Improvements or additions to documentation i On iOS & iPhone. (Subject) meta Involving THE PSALMS and/or this repo

Comments

@extratone
Copy link
Owner

extratone commented May 6, 2021

And a Magic Keyboard is the real kicker, I suppose.

WF Workflow Social

https://mastodon.social/@DavidBlue/106621130332857798
I can’t help it… time to get back to the “Insane Full-Throttle Write.as Publishing IPHONE ONLY Workflow” …workflow… guide. here begins its thread (can’t remember if I’d already started one.) #128
—-
https://mastodon.social/@DavidBlue/106621135526473737
so this take is definitely gonna have to be deleted b/c of my puppy… but GitHub just let me upload the whole fucking thing? cool

this is actually pretty much the gist of the “Development” worth demonstrating - in this case, editing CSS with Kodex, previewing it with @write_as‘s new CSS.horse tool (almost lol,) and Git-enabling all of it with Working Copy. https://user-images.githubusercontent.com/43663476/126570421-a0316032-573f-4507-8fa6-a4e0a8f03d99.MOV
—-

@extratone extratone added documentation Improvements or additions to documentation meta Involving THE PSALMS and/or this repo i On iOS & iPhone. (Subject) dev Development! labels May 6, 2021
@extratone extratone self-assigned this May 6, 2021
@extratone
Copy link
Owner Author

...and five geee, I suppose....

extratone added a commit that referenced this issue May 6, 2021
extratone added a commit that referenced this issue May 6, 2021
extratone added a commit that referenced this issue May 6, 2021
Moved notes and drafts files to their appropriate directories.
@extratone
Copy link
Owner Author

Hardware

  1. iPhone 12 Pro Max - 256GB, Pacific Blue. (MGCN3LL/A)
  2. [Magic Keyboard with Numeric Keypad - US English - Space Gray](https://store.apple.com/xc/product/MRMH2LL/A)
  3. Tylt Crest Convertible 3 Coil Wireless Charger

image

Hilarious that Tylt is bragging about tree planting already - might as well get it in place ASAP though for when the public realizes your chargers are 40%+ less efficient than just... Plugging the fucking phone in.

@extratone
Copy link
Owner Author

![Title Preview}(https://user-images.githubusercontent.com/43663476/117581148-f96fdf80-b0c0-11eb-8be6-ac9d9666d8b1.png)

extratone added a commit that referenced this issue May 15, 2021
extratone added a commit that referenced this issue May 15, 2021
extratone added a commit that referenced this issue May 15, 2021
@extratone
Copy link
Owner Author

@extratone
Copy link
Owner Author

"Using Pandoc on iOS (Sorta) | W. Caleb McDaniel"

By W. Caleb McDaniel
''


hacks

Posted by W. Caleb McDaniel on May 3, 2013

As I’ve explained before, I now do almost all of my writing—including my academic writing—in plain-text, Markdown files. I then use the incomparable document-conversion tool, Pandoc, to turn these files into HTML, Microsoft Word documents, PDFs, or EPUBs. Even this website is produced with Pandoc.

One virtue of this preference for plain-text files is that it enables me to write on my iOS devices. Plain text is mobile. But Pandoc is not, or so I have long assumed. Because Pandoc is a command-line utility, my ability to convert Markdown into Pandoc’s other file formats has so far been tethered to my laptop.1

Enter Docverter, an open-source tool that makes it possible to use Pandoc without having it installed on your machine. To use it, you post multipart/form-data requests to a URL and get Pandoc output as a response, using the Docverter API to select which Pandoc options you want to use. So, for example, you can send Markdown text to Docverter and get back formatted PDF output, which you can then write to a PDF file—all without having a computer with Pandoc installed.

But can you use Docverter without having a desktop or laptop computer at all? At first glance, no: the documentation suggests using another command-line Unix utility, curl, to make requests to Docverter. But you can’t use curl from an iPhone or an iPad, or at least not easily. If you want to use Pandoc from an iOS device, you need a different way to access Docverter.

Pythonista + Docverter = iPandoc (Sorta)

The solution is Pythonista, an inexpensive iOS app that allows you to write and execute Python scripts, including ones that interact with web services like—you guessed it—Docverter. Last weekend I spent a day writing a script that uses httplib, one of the standard Python libraries included with Pythonista, to post requests to Docverter from my iPad and get back Pandoc output.

You can grab the script, with explanatory comments, as a Gist.

Briefly put, the script works like this. I open a text editing app like Nebulous Notes and put some Markdown text on my iOS clipboard. I open Pythonista and run my iMDtoPDF script. A few moments later, a PDF output file appears in my Dropbox.2

This method will help me quite a bit in the following sort of situation: I am away from my laptop, but I need to email a long, footnote-heavy document to someone. Or a student requests a recommendation letter that is due before I can get to my computer, and I need to create a PDF version with letterhead from the plain text version of the letter that I keep under version control. Now I can run this script, go to my iOS Dropbox app, and email the PDF file from there, all without leaving the iPad.

In other words, I can use Pandoc on the iPad … sorta. I haven’t yet figured out how to utilize all of Docverter’s options in my script. And unlike Pandoc, Docverter does not use LaTeX to produce PDFs. Instead, it converts Markdown to HTML and then uses a service called Flying Saucer to print that HTML to a PDF. Nonetheless, this method still allows you to control some of the styling of the PDF by using a CSS stylesheet and embedded fonts. For example, here’s the PDF output of this post using the CSS declarations included in my script.3

Extending the Script

In the Gist version of this script, I’ve deliberately kept things simple. But the version I’m using has several extended features.

For example, the public version automatically gives the output PDF file a generic, time-stamped name. But you can use Pythonista’s console module to prompt yourself for a specific title.

## Name output file with user input
import console
title = console.input_alert('Output filename', 'Enter title below')
outfile = title + '.pdf'




By adding these two lines to the end, I can also have the script automatically open the output file in [GoodReader](http://www.goodiware.com/goodreader.html), where I can then preview, annotate or email it:





## Get temporary URL for file in Dropbox
share_url = dropbox_client.media(outfile)
url = share_url.get('url', 'not found')

## Prefix the URL with 'g' to open in Goodreader
import webbrowser
webbrowser.open('g' + url)




Python makes numerous other features possible: my modified version, for example, prints a timestamp in the footer of the PDF’s first page. And Docverter itself can be used to extend the script: with a slight tweak of the script’s fields variable, for instance, you can output Docx files or EPUB files instead. Finally, by stringing together Pythonista with other apps like Drafts, it’s possible to automate this script without having to manually launch Pythonista every time a conversion takes place.4




These solutions, to be sure, do not bring Pandoc in all its glory to the iOS platform. But they do _sorta_ make Pandoc mobile. And I think that’s sorta cool.







* * *






  1. I should note that many iOS text editors now feature the ability to create Markdown previews or convert Markdown into HTML. But they lack some of the features of Pandoc that I most rely on, like footnotes and PDF output.↩



  2. The ability to upload the file to Dropbox requires taking two other steps in addition to this script. First, you have to create a free Dropbox development app. Then, you have to create [this separate script](https://gist.github.com/4034526) in Pythonista; it includes a function for interacting with the Dropbox API that is called by my script. For more information, see [Using the Dropbox module](http://omz-software.com/pythonista/forums/discussion/10/using-the-dropbox-module/p1) in the Pythonista forums.↩



  3. Flying Saucer’s method of producing PDFs does have disadvantages over Pandoc’s native use of LaTeX; for example, you’ll notice in the PDF version of this post that quotation marks within code blocks are converted into HTML character codes, which wouldn’t happen if I had made the PDF using Pandoc on my laptop. For most of the mobile use cases that I can imagine, however, Flying Saucer should fine.↩



  4. For tips on automation and a ton of other Pythonista ideas, see Frederico Vitti’s [monster post](http://www.macstories.net/stories/automating-ios-how-pythonista-changed-my-workflow/) on Macstories.↩

-"Using Pandoc on iOS (Sorta) | W. Caleb McDaniel"

@extratone
Copy link
Owner Author

"A Machine Learning Workflow for the iPad Pro"

**By ****
'May 23, 2020 at 12:00'


__ 20 minute read

__ Published:

The iPad is a revolutionary device. I take all my notes with it, read & annotate papers and do most of my conceptual brainstorming on it. But how about Machine Learning applications? In todays post we will review a set of useful tools & venture into the love story of the iPad Pro & the new Raspberry Pi (RPi). Afterwards, you will be empowered to establish your very own “mini”-ML workflow, know the ML-tailored application landscape & get started with setting up a RPi as an iPad-powered USB-C device. More specifically, we will discuss how I integrate a set of useful apps in my daily research routines, how I got started with the iPad & RPi and how one can use the iPad to run larger compute jobs on remote servers. So let’s get started with today’s agenda:

  • Apps which I use throughout my daily research! :mag:
    • Note Taking & Paper Annotation with Notability & Procreate :pencil2:
    • Connecting to remote machines with blink.sh :eyes:
    • Editing and version control with Kodex & WorkingCopy :floppy_disk:
    • Connecting to Jupyter Servers with Juno Connect :satellite:
  • iPad Pro + Raspberry Pi Model 4B = :heart:
    • Equipment, equipment :wrench: - What do we need?!
    • Steps to setup the Raspberry Pi :strawberry:
    • Steps to setup the iPad Pro :iphone:
    • Compute, COmPUtE, ComPUTE :chart_with_upwards_trend:
  • Some Tricks of the Trade :hammer:
  • Some concluding Thoughts :thought_balloon:

Apps which I use throughout my daily research! :mag:

The iPad Pro has been one my the best financial investments. It is primarily designed for multi-media creatives who need an intuitive and efficient workflow. This includes artists, creators and media editors. Not necessarily people who would like to program. Only recently, Apple has been pushing towards making the iPad Pro a stand-alone computer replacement. The biggest step towards this is the USB-C port which allows for simultaneous charging and data exchange. In combination with the new iPadOS we can start to dream & experiment. Furthermore, recent updates to apps and new launches introduce a plethora of possibilities for the code savy peepz. Here are some of my favourite ones:

Note Taking & Paper Annotation with Notability & Procreate :pencil2:

I use the majority of my “iPad time” reading papers, taking notes at talks or brainstorming sessions for projects. There are many options which allow you to do so. I personally really enjoy Notability. It is very flexible while being minimal in its design. A feature that I greatly appreciate is the ease of cropping text snippets & how you can smoothly include images from presentations/white boards/online search. After being done writing or if you want to share your notes, you can export them to any cloud storage or share them via AirDrop/email. This makes collaborating super easy! I also use Notability for all the visual-ml-notes (check out the repository). Finally, a feature which I am not using enough (but should) is the audio recording & playback of notes. Notability allows you to record while writing. Afterwards, you can simply press play to get a form of video of the creation process of your notes while listening to the audio again. You can “tap” into the note and the audio timeline will automatically jump to the audio that was recording at the time of writing. Pretty neat, right? If I want to be a little more artsy, I like to go with Procreate. Sometimes it is really relaxing to simply loose yourself in some fine details of a drawing (sometimes I wonder whether Sundays were made for “peocreat-inating”). My recent blog thumbnails are illustrated in Procreate. Procreate is a “serious” app for artists (and arts lovers :hugs:) and has tons of features to tune colours, drawing styles, canvases & so on. I got to admit - the shear amount of options was initially a little overwhelming. And that’s where the world wide web came to rescue me. There are soo many awesome YouTube tutorials out there. Even if you are not the most talented at drawing (which I am most definitely not) Procreate has a set of tools to support you (line snapping, different layers, etc.). Something I really enjoy is the mirroring option which makes every little doodle appear as a calligraphic master piece (maybe I am exaggerating a little here).

Connecting to remote machines with blink.sh :eyes:

Often times when I attend conferences, I don’t want to carry my laptop since I know that I won’t be getting serious amounts of focused time to work on projects. But I still might run some jobs or test some hyperparameter intuition. In that case I simply need some way to tunnel into my remote machine so that I can monitor what is going on and start new jobs on demand. And that’s where blink.sh comes in. Blink is a Mosh (mobile shell) application which lets you smoothly ssh into any remote machine of your choice. Blink allows you to setup multiple hosts & shortcuts for your ssh servers. I have setup a couple for a small AWS EC2 instance, my lab’s cluster and my Raspberry Pi (more on that later). Given an LTE connection I can log into the host machine from wherever without any hastle of setting up hotspots. Once you are logged in (and have mastered a terminal emulator like [tmux](https://gist.github.com/andreyvit/2921703)/`[screen`](https://gist.github.com/jctosta/af918e1618682638aa82)) you have ported all the remote capabilities of an regular Linux OS to the iPad! There is one more awesome feature of Blink I need to tell you about: Using an external monitor and multiple Blink windows. All you have to do is hook up your iPad to an external monitor via USB-C. While usually the external monitor is synced to your iPad, Blink Shell automatically projects a second window onto the external monitor so that you can get full use out of your setup. You can then easily switch between Blink windows using cmd + o and within Blink windows with remote tmux sessions & ctrl + b + arrows. To me this feature is really crucial in making me feel like I can seamlessly switch between doing smaller type tasks in the train & switching into more serious work in an office-type environment.

Blink is minimal in its design and focuses on the mosh/ssh service. A few things that I am looking forward to being integrated (or maybe haven’t discovered yet) are the following:

  • Splitting blink panes: Sometimes one would like to log into two separate machines at the same time. No problem for Blink. But one has to create a new Blink ‘window’ & maneuver between them. Instead I would like to split the current window into multiple panes.
  • A way to vim edit files directly on the iPad itself & integration with the iPadOS file system.
  • Some easy way to rsync files from iPad to a remote machine & the other way around.

Editing and version control with Kodex & WorkingCopy :floppy_disk:

If I want to code something locally on the iPad, this usually involves 4 main steps:

  1. Locally clone a repository from my GitHub using the version control app WorkingCopy.
  2. Edit the necessary files locally using the free & awesome Kodex editor.
  3. Test the code using either a local IDE (such as e.g. Pythonista3 or Juno for Jupyter - see below) or doing so remotely after copying over the files using scp.
  4. commit and push the edits back to your desired repository branch again with WorkingCopy.

WorkingCopy allows you to connect your iPad with your GitHub account and provides all the version control functionalities that one may need. Kodex, on the other hand, is a text editor for the iPad which supports linter utilities for almost all programming languages. You can directly edit files from your cloud storage (Dropbox, etc.) or locally on the iPad. Both, Kodex and WorkingCopy, are free of any charge!

Connecting to Jupyter Servers with Juno Connect :satellite:

So let’s review what we have covered so far: Paper work and artsy stuff, connecting to remote machines & editing/managing code-based projects. What are we missing? Exactly, the favourite application of every data scientist - Jupyter notebooks - and here is how to do Jupyter on the iPad: The Juno collection of apps provides us with two options to setup/connect to Jupyter servers & work with notebooks either locally on the iPad or on remotely:

  1. Juno for Jupyter: The local edition allows you to run notebooks directly on your iPad. You can install packages via the standard PyPi repository. From there on you are free to prototype. Note: Having a full-“mini” environment on your iPad can be helpful, but I personally prefer running things through the Raspberry Pi if I don’t have any internet connection (see below).

  2. Juno Connect for Jupyter: My true all-star is Juno Connect. The connect-version makes it super simple to tunnel into any port through which you have forwarded a remote jupyter server. This is done via launching and exposing the jupyter port via jupyter notebook --ip 0.0.0.0 --port 8899 --no-browser on your remote machine.

The user interface and notebook rendering then looks like this:

Something that I am missing from Juno and would love to see in the future are functionalities of Jupyter Lab which includes support for system shells as well as other nice extensions. One of my favourite features of Jupyter Lab (compared to plain Jupyter notebook) is the built-in terminal multiplexer which allows you to easily switch between command line and notebook editing.

iPad Pro + Raspberry Pi Model 4B = :heart:

The iPad Pro by itself does not have a full operating system and should also not be thought of as a compute machine :robot:. While Apple claims that the 64-bit A12X/A12Z bionic chips are faster than many Windows computers, their performance is optimized for graphics operations such as rendering/4K editing/gaming and not for running Python code. And this is where the Raspberry Pi comes in. The new quad-core RPi model 4 comes in a couple of different variants (1/2/4 GB) RAM - and most importantly with a USB-C connection which can power as well as exchange data simultaneously. It is not bigger than a pack of cigarettes 🚬 & can easily be hooked up to the iPad Pro. So what are the main benefits of this setup?

  1. You are able to prototype small applications - always and everywhere.
  2. You have an extended (and glorified) dongle with you. The RPi has a set of USB 2.0 and 3.0 ports as well as an audio jack.
  3. You have smoother git/version control support through Raspbian Buster/the Linux environment.
  4. You are no longer dependent on a stable internet connection to log into remote servers.
  5. You can mount external SSDs/storage to exchange larger files with the iPad and to have a backup with you at all times.

So how do we make this work?

Equipment, equipment :wrench: - What do we need?!

So what are the ingredients I am currently using in my setup? Here is a short list:

  1. An iPad Pro 3rd (or higher) generation with USB-C.
  2. A RaspberryPi Model 4 again with USB-C. There are many starter packs which give you everything you need to get started for a reasonable price.
  3. A set of basic RPi basics including a micro-SD-card, some heat sinks and a way to keep the Pi cool (for mini-overclocking of the CPU).
  4. A USB-C to USB-C cable that can charge the RPi which we will use to connect the iPad with the RPi. Note that the RPi does not support every USB-C cable. I am using a cable from Anker.
  5. A way to connect the RPi to a screen for an initial boot (e.g. micro-HDMI cable).
  6. A fast external SSD to swap around files & data. (I am using the Samsung T5 with 500 Gigs)
  7. A bluetooth compatible mouse. (I am using the Logitech MX Master 2.)
  8. Additional RPi gadgets & extensions such as sensors and a camera.

The last three are all optional can can smooth out the experience.

Steps to setup the Raspberry Pi :strawberry:

  1. Download a tool for flashing OS images (e.g. Etcher).
  2. Download a Raspbian Buster image and flash it onto the Pi’s Micro-SD. Afterwards, insert the Micro-SD slot of the Pi (on the back of the board).
  3. Put the Raspberry Pi in the case, attach heatsinks and the fan (using pins 4 and 6).
  4. Boot the Pi and set a new password. Afterwards you can connect your RPi to the internet.
  5. Set up Miniconda 3 (e.g. using these instructions).
  6. Set up the Pi as a USB-C device by following these instructions.

Note The correct final instruction should be add sh /root/usb.sh to /etc/rc.local.

The first steps are a lot easier if you have access to an external monitor to check that everything works out as desired.

Steps to setup the iPad Pro :iphone:

At this point you are ready to get everything rolling on the iPad:

  1. Download a shell client. For example my favourite Blink shell.
  2. Connect the Raspberry Pi to the iPad via USB-C. At this point the Pi shoot detect a power source and start booting up. This may take 30 seconds.
  3. Go to the settings, inspect if there is a new “Ethernet” flag and make sure the Pi is detected. If not please make sure that step 6 of setting up the RPi as a USB-C device was successful!
  4. Go to your iPad shell and SSH into the Pi via ssh [email protected] which is the static IP we set before. You should then be able to login using your RPi username and password.

You should have logged into the RPi for the first time and we are now able to dive deeper. The full RPi-iPad setup looks something like this:

Next things to do :information_desk_person:

You have made it & can now start customising all the features according to your needs! Some of my first steps included the following:

  • Setting up LTE usage via creating iPad Hotspot and automatically connecting the RPi to your WiFi. For that I used a shortcut (see final section on tricks of the trade).
  • Install Jupyter and use Juno packages to create a working environment.
  • Setup hosts in the Blink shell and start working on other remote machines.
  • Become comfortable with tmux or screen to work with multiple terminal panes.
  • Become comfortable using a command line-based editor like vim or nano for editing.

In my experience the RPi does not suck too much power from the iPad. Without any power source, a full iPad charge gives me around 5+ hours of RPi usage (at medium compute and with active fan). This is usually more than enough for me. Something that might come in handy can be a USB-C adapter with two USB-C ports. This way you can charge the iPad while at the same time powering the RPi.

Compute, COmPUtE, ComPUTE :chart_with_upwards_trend:

At this point we have discussed two main ways how to do scientific computing with the iPad:

  1. Use a remote server and ssh into it using Blink.sh.
  2. Use Juno Connect as a comfortable way to port your Jupyter server.

And now we have so many more options:

  1. RPi + Miniconda/Docker + Jupyter Notebook Prototyping + Intel’s Movidius Neural Compute Stick

As previously mentioned Juno also lets you connect to a notebook running on your RPi. In order to do so, you simply have to setup Miniconda (with Python >= 3.6) on the RPi and then again run a browser-less notebook process with port forwarding. And you don’t even need any internet connection!

Some Tricks of the Trade :hammer:

Managing files with external SSDs, scp & Netatalk

One of the advantages of the RPi is always having a supercharged adapter dongle with you :smile: This allows you to make better use of the single USB-C port of the iPad and opens up the possibility of exchanging files between the RPi and the iPad. One of the first things I did was to mount a SSD drive to the RPi and to automate the process when booting up. This allows you to explore larger datasets on the RPi & to keep a backup of my main laptop with me at all times. Furthermore, the iPad’s file system allows us to easily pull files from our RPi onto the iPad or any computer.

Using the new iPadOS shortcuts application to integrate things smoothly.

Shortcuts come in really handy when booting & setting up the RPi and more generally during everyday activities. Here are a few of my favourites:

  1. Powering off the RPi via shortcut by TechCraft
  2. Connecting the RPi with WiFi via shortcut by TechCraft
  3. Sharing file size reduced images by Jason Snell

Monitoring Remote Tensorboard Loopback addresses with ngrok

Another cool general tool to have under your belt is ngrok. ngrok allows you to access local servers from a public URL. As the word public may already tell - security is not necessarily guaranteed and may require some additional effort from your side. I mainly use ngrok to implicity forward a port which I use for simple monitoring of tensorboards. The reason for that is that I haven’t found a way to do so solely from within blink shell. After signing up & installing ngrok you will have to add an authentification id to your ngrok config and then tensorboard port forwarding is as simple as:

  • Start tensorboard on a port of your remote machine: tensorboard --logdir experiments/tboards/ --port 6006
  • Expose the port to a public URL (also from the remote machine): ./ngrok http 6006

ngrok will then forward your localhost instance to a web URL with .ngrok.io extension. And you can thirst your learning curve quench from wherever you are :smile:.

Some concluding Thoughts :thought_balloon:

Wow this was quite a bit of text & images :smile:. But there is still soo much more to talk about (e.g. markdown editing with Bear). In the future I look forward to setting up a small Kubernetes cluster on a set of RPis. Currently I don’t really have any use for it, but it would be a great (and not too costly) learning experience - given that I know little about distributed compute. Furthermore, I would love to get JAX to run on the RPi. As of right now there is an open issue to create ARM wheels similar to how TensorFlow can be installed on a RPi. The CPU speed-up could really facilitate some of my mobile Deep Learning projects.

A few final public service announcements:

:point_right: Inspirational props go out to Rob’s (nope another one) YouTube channel TechCraft. He has an awesome video on powering a general RPi setup with the iPad Pro. Check it out!

:point_right: Most of the covered apps and setups cost money. I have always believed in investing into education & tools that make me most productive. But you might think differently or be in a different position. And that is okay. For most of the things I cover in this blog, there are free alternatives & you don’t need an Apple tablet to create a similar workflow.

:point_right: I am not getting paid/gaining anything from the app companies, Apple or anyone for writing this blog (never thought I would write this :bowtie:). I simply like to share things that I love and make my life easier.

Happy tooling with your new setup,

Rob

P.S.: Let me (@RobertTLange) know if I missed out on your favourite tool!

-"A Machine Learning Workflow for the iPad Pro"

@extratone
Copy link
Owner Author


toc: true
layout: post
description: My iPad computing setup
categories: [setup]
title: My iPad Setup

Caveats and Story

My laptop is broken. I am away from office. I have an iPad Pro 2020. I got my office desktop's magic keyboard and trackpad. In this post I am discussing if iPad can help given that I do not have (physical) access to my main computers. Would I recommend this over a main computer - No! But, can you do some things on the iPad reasonably well enough given keyboard and trackpad - Yes!

The Hardware

The magic keyboard and the magic trackpad greatly increase the iPad experience and make it programmer friendly.

![]({{ site.baseurl }}/images/IPAD-Photo.jpeg "Magic Keyboard and Trackpad")

Setting up an iPad for programming

Setting up the terminal app (a-Shell)

Configuration

First, after installing a-Shell, I like to set the font size, terminal background and foreground color. Here is how the a-shell app looks like

![]({{ site.baseurl }}/images/A-shell-initial.png "a-shell on the iPad is my favourite app!")

config -b black -f white -s 20

Text editing and bookmarks

Sometimes I like using vim for editing documents and interfacing with WorkingCopy. a-Shell provides vim!

I like to setup a bookmark to the WorkingCopy folder so that I can direcly edit files in that location.

I do so by:
writing pickFolder in a-Shell and setting it to WorkingCopy folder. Now I can set a bookmark to this location. I do so by:
bookmark git in the current location (set by pickFolder)

![]({{ site.baseurl }}/images/Bookmark-Git.png "Setting Bookmark location to WorkingApp -> git")

Git

Interestingly, the latest testflight version of a-shell also provides a "Git-like" interface called libgit2. Configuring it requires specific steps that I'm writing below. Some of these steps are borrowed from this nice tutorial and some are specific to a-shell that I was able to get working courtesy a Twitter discussion with the creator of a-shell.

![]({{ site.baseurl }}/images/Twitter.png "Twitter discussion with the creator of a-shell")

Now, the steps.

First, we need to create a new ssh key.

We do so by

ssh-keygen -t rsa -b 4096 -C "[email protected]"

While configuring I did not setup the passphrase.

The private and public keys are stored in .ssh with the name id_rsa

$ ls -lah .ssh|grep "id"
-rw-------   1 mobile  mobile   3.3K Jun 14 15:43 id_rsa
-rw-------   1 mobile  mobile   747B Jun 14 15:43 id_rsa.pub

Next, I copied the public key in a newly generated ssh key in Github and gave it a name.

Next, I modified .gitconfig as follows

$ cat .gitconfig 
[user]
        email = MY EMAIL ID
        name = MY NAME
        identityFile =  id_rsa 

Now, I was almost done!

I was able to push and pull from some old Github repositories but the same did not work with the newer repositories. Again, after a discussion with the creator of a-shell, I figured, this was due to the fact that Github changed the name of the default branch as "main" instead of the earlier "master" whereas libgit2 implementation was expecting "master".

As a quickfix I renamed the branch on my Github repo as "master" and for now set the default branch to be named "master".

Finally, I am able to pull and push to the repositories. The next image infact is showing commits and pushes made to the repository generating the blog post you are reading.

![]({{ site.baseurl }}/images/libgit-2.png "libgit2 push and commiting")

SSH/SFTP

There are a couple of amazing apps: Termius and SecureShell. Both have very neat interfaces. I found the intergrations with the Files app very good!

The GIF below shows the SecureShell app in action where I transfer a file from my local storage (iPad) to remote server, process that file, and quickly copy the processed file back to local storage.

![]({{ site.baseurl }}/images/SecureShell.gif "Working with SecureShell is amazing!")

Another great functionality of the SecureShell is the "Offline" folder.

Another setting that I use is the Powerline fonts on my remote systems. Using Fontcase, I installed the corresponding powerline fonts on the iPad so that my SecureShell session looks great.

![]({{ site.baseurl }}/images/powerline-combined.png "Powerline fonts installed via Fontcase allow special characters on the remote terminalls (above image without powerline font on iPad, below one with powerline font")

Some other amazing tools

I like the "view" utility in a-shell a lot. It can quickly help you preview various filetypes.

![]({{ site.baseurl }}/images/view.gif "The view utility in a-shell")

Also, as a quick tip, one can use Command + W to quickly exit the preview and use the back and forward keys to cycle through the files. This is very useful!

I also like the fact that the convert tool now comes in inbuilt. It can convert between a variety of formats easily.

pbcopy and pbpaste are very convenient utilities to copy to and from the clipboard. Here is how I copied the content of factorial.py into the clipboard.

pbcopy < factorial.py  

Shortcuts

a-Shell interfaces nicely with Shortcuts. The following gif shows an interface where I take an input from Shortcuts app -> Pass it to a Python script and execute it inside a-shell -> Store the results in a text file -> View the content of the text file in Shortcuts.

![]({{ site.baseurl }}/images/shortcuts.gif "Using shortcuts in a-shell with Python!")

The link to this shortcut is here

The following is the simple Python script I used called factorial.py

import math
import sys

num = int(sys.argv[1])
print(f"The factorial of {num} is {math.factorial(num)}")

The following is an image of the shortcut.

![]({{ site.baseurl }}/images/Shortcut-Working.png "Using shortcuts in a-shell with Python!")

Based on the suggestion here, I used pbcopy to copy the content to the clipboard and use it directly. It reduces the number of lines!

![]({{ site.baseurl }}/images/Shortcut-2.png "More efficient version using clipboard")

Using the WorkingCopy App

WorkingCopy is a very nicely made Git app on the iPad. It is one of the best made apps I have used!

I'll let the pictures do the talking.

![]({{ site.baseurl }}/images/Working-Copy-1.png "WorkingCopy App interface")

![]({{ site.baseurl }}/images/Working-Copy-2.png "WorkingCopy App interfaces nicely with the Files app!")

![]({{ site.baseurl }}/images/Working-Copy-3.png "WorkingCopy App can nicely show the diffs")

Editors

I use one of the following for editing:

  • Koder App
  • WorkingCopy App
  • vim (in a-Shell)
  • Textastic
  • Typewriter for Markdown — is an editor only for markdown but gives a nice quick preview. The image below shows the screenshot from Typewriter for Markdown app.

Setting Linux/Mac machine and iPad for Python programming (via Jupyter notebooks)

On the Linux/Mac (remote server) machines I set up Jupyter notebooks as follows:

First, I create the configuration file via: jupyter notebook --generate-config

Next, In ~/.jupyter/jupyter_notebook_config.py change

c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.allow_origin = '*'
c.NotebookApp.port = SET YOUR PORT
c.NotebookApp.open_browser = False

Set password using:

jupyter notebook password 

Run notebook as:

nohup jupyter notebook& 

On the client end (iPad in this case), I use one of the following two ways to access remote Jupyter instances:

  • Using the Juno Connect app
    Juno connectly nicely saves all the configuration and can do the necessary port forwarding

  • Using Safari and opening the remote Jupyter URL
    Just open the remote URL with the set port number. I use my workplace recommended VPN client to get into my workplace network and access non-public IP based servers.

VNC connection

I tried a few VNC software and found AnyDesk to work fairly well. I did a bunch of small settings tweak.

  • I setup a password on my remote machine for uninterruped access
  • I put AnyDesk in the login items on my remote machine so that it starts when the system boots

Email client

I like the Spark app.

  • The interface is pretty clean.
  • It has a bunch of keyboard shortcuts making it nice to use with an external keyboard.
  • It is trivial to interface with various cloud providers.
  • It is trivial to save an email as a PDF.
  • It is trivial to create a "link" to an email for sharing.

PDF management

The iPad Files app is a fairly well made app. Perhaps not as functional as the Mac Preview app, but, does some things well.

For instance, merging multiple PDFs is easier (for me) than doing the same on Mac. One just needs to select multiple files and then "right" click to "Create PDF"

![]({{ site.baseurl }}/images/CombinePDF.gif "Combining PDFs is trivial on the iPad using Files app")

I use the following ffmpeg command (inside a-Shell) to create this GIF courtesy this excellent tutorial from GIPHY folks

PDF viewing

The Documents app has a very nice pdf viewing experience. It gives the "full-screen" experience on connected displays and can potentially be an excellent pdf viewer for showing my slides on the projector in the classroom setting.

![]({{ site.baseurl }}/images/PDF-view.png "Documents app is an excellent PDF viewer!")

Another advantage of the Documents app PDF viewer is that we can change the tone to Sepia or Dark. The following image shows the view I get when I change the tone to Dark.

![]({{ site.baseurl }}/images/PDF-view-dark.png "The dark tone with the click of a button is an amazing feature!")

When connected to an external display, the PDF viewer gives various options. In the next image, I show the view when I "focus" on a part of the slide.

![]({{ site.baseurl }}/images/PDF-view-focus.png "Focusing on parts of pdf")

Finally, the image below shows the "focused" slide on the external display.

![]({{ site.baseurl }}/images/PDF-screen-focus.jpeg "Focusing on parts of pdf on external display")

ffmpeg -i Video.MP4  -filter_complex "[0:v]  fps=12,scale=720:-1,split [a][b];[a] palettegen [p];[b][p] palette
use" CombinePDF.gif

Another alternative is to use the following shortcut to convert the screen recorded video into a GIF

Some Safari keyboard shortcuts

  • Command + W for closing a tab
  • Command + L for going to the address bar (sometimes on tabs I am not automatically on the address bar)

Conclusions (and rants)

For the long run, ofcourse, I would not recommend this kind of a setup. There is some learning and fun in getting a "resticted" device to function well, but as a main machine, probably no, at least not for the next few months. A comparably priced laptop (say M1 Macbook Air) would offer a lot more.

There are many things I'm missing:

  • Projection to a projector and screen recording do not work at the same time.
  • No proper dev environment like VSCode
  • A lot of screen size is "wasted" due to the OS
  • A lot of the apps are not as good as I'd like. For instance, perhaps a minor thing, but the Youtube app doesn't have a keyboard shortcut for full screen. One can ofcourse do the same on Safari. iMovie in Mac has a remove background noise feature that works very well. The iPad version does not have the same.
  • Safari though much improved over the years is not as functional as Safari on the Mac
  • While quicklook/Files is good, the functionality of something like Preview is hard to beat
  • The files app can not show hidden files and folders
  • Powerpoint does not have features like audio recording (though can play)
  • Keynote, Pages, Numbers require additional clicks than their Mac counterparts
  • When I connect to an external display, I get thick black bars and moreover, if the monitor does not give me an HDMI out, I can not hear audio as the audio is also routed. As good as the iPad's display is, it is not huge and strains my eyes after a while.
  • Copy pasting using the keyboard is a hit and miss. For instance, it fails several times for me when copying from a pdf. Right clicking and copy seems to always work, but, it is more steps than Command C, Command V.
  • I miss some quality apps like OBS Studio, especially being an academic teaching remotely due to the pandemic.
  • While a-shell is amazing, it is limited by what webassembly can do. At the time of writing, it does not support multithreading and thus the performance of utilities like ffmpeg is severely limited. Also, a-shell programs can not be stopped intermediate in their execution. See the following two bugs on Github related to this:

Some of the above may be resolved over the next updates and the major iPadOS15 updates. Though, I do not expect most of them to be resolved anytime soon.

@extratone
Copy link
Owner Author

The Development Delirium

![Working Copy, Kodex, and CSShorse on iPhone.](https://i.snap.as/ZVSxsMvR.png)

image

Upload.from.GitHub.for.iOS.MOV

...whoa.. I did not expect GitHub to allow such a huge upload!! Obviously, this particular recording needs to be discarded, but u get the "gist"... lol

extratone added a commit that referenced this issue Jul 27, 2021
@extratone extratone moved this to Documentation in The Psalms Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev Development! documentation Improvements or additions to documentation i On iOS & iPhone. (Subject) meta Involving THE PSALMS and/or this repo
Projects
Status: Documentation
Development

No branches or pull requests

1 participant