3 ms·
Maybe I'll write a guide up! I've got a pretty good setup going. Pending full write up, here are some key pieces: Shortcuts side: the shortcuts app is really
by paultopia 8y ago
Maybe I'll write a guide up! I've got a pretty good setup going.
Pending full write up, here are some key pieces:
Shortcuts side: the shortcuts app is really shockingly powerful, mainly because you can share almost anything you want into it and it intelligently figures out what you want. For example, if you share a web page from safari into it, if the first action receives a url, it'll treat it as such, if it receives a web page it'll take the DOM and not worry about the URL, etc.
There are really three key actions.
1) `Get contents of URL` allows arbitrary http requests. You can pass in data from other actions. This is the main workhorse for heroku things.
2) `Run JavaScript on web page` allows you to just run arbitrary JS in the context of whatever page you share into it. It's great for data-collection type tasks, you can just rip whatever you need out of the DOM and POST it away per the above, and then shove it into a database from heroku.
3) `Run Pythonista script` does what you'd expect. It passes whatever the action receives into Pythonista as a command line argument. And then, obviously, anything goes. If you haven't tried Pythonista, you should check it out---it's hard to get 3rd party libraries in (and many don't work), but you get the full stdlib plus a bunch of key libraries that the dev has taken the trouble to build in, including numpy, requests, matplotlib, beautifulsoup, PIL, sympy, etc...)
After receiving a response from heroku, it's trivial to save it to iCloud/Dropbox, put on clipboard, open a preview window with a share sheet available, etc.
On the Heroku side, the key trick is that you can run Docker containers. So, for example, my mobile pandoc solution is a docker container that has texlive and pandoc on it, allowing me to have basically a personal improved docverter. So I just post a markdown document via shortcuts to a flask endpoint that converts the document and returns it to me as the response.