DEV Community

Cover image for Programming On The Go When You Only Have A Phone
Justin Ho
Justin Ho

Posted on • Updated on <time datetime="2021-10-19T03:51:14Z" class="date-no-year">Oct 19</time> • Originally published at jcsh.dev

Programming On The Go When You Only Have A Phone

Cover Photo by Mika Baumeister on Unsplash

This is a follow-up / extension of my other post, Using the Cloud As Your Mobile Workstation, check it out if you haven't!

What This Post Is About

No this is not a tutorial to code an Android app

Last week I happened to be away from home all day and only left with an ultra-thin laptop to work on. The laptop's battery would not have lasted me the whole day if I ran my virtual machines. As I pointed out in my post above, my solution was using a cloud virtual machine as a workstation, because it was inexpensive for the amount of compute power you get running it for one day and it preserved my laptop's battery.

Today's post however, goes one step further, and details how you can work on your programming projects using an Android device.

Why Would You Want To Do This?

"...your scientists were so preoccupied with whether or not they could, they didn’t stop to think if they should."

In the current COVID-19 pandemic of 2020, many businesses and establishments do not offer their regular sit-in / walk-in spaces. So imagine my surprise when I went to drop off my car for a check-up only to find out it would take 2 hours instead of 20 minutes. And there was nowhere to sit. And I only had my phone on me.

"Why don't you go to the (fast-food place with a clown) down the road?"

Unrelated Coffeshop Image

Photo by Jonas Jacobsson on Unsplash

So there I was, sitting on the counter, sipping on my iced coffee and scrolling through social media all by myself, when a thought hit me: "why don't I work on my project?"

The How I Did It

The process is actually easier than you might think, and there are even software as a service platforms such as GitPod which offers a VSCode instance in a chrome browser. However, I was more comfortable using a command line and using short-cuts for VIM on a touch keyboard felt more natural than on VSCode. But how do I get a terminal on my phone?

Enter Termux

Termux is an open source terminal emulator for Android, providing a sand-boxed Linux-like environment for you to access using a console interface. It doesn't require me to root my phone (which I couldn't have without another machine) and it was available on F-Droid. It's a truly wonderful project, and perfect for what I wanted to do.

Now, I wasn't about to install all my project dependencies on my phone. The bandwidth of public Wifi combined with my phone's battery would make sure I never finish setting up the project before my car was ready.

Instead, I just reused what I had in my last post: a cloud-based virtual machine to work on, but this time, with my phone as a thin client.

The Cloud, Round 2

Last time, I created a snapshot (a copy in time) of both the virtual machine with my development environment and the block storage with my project. The benefit of these snapshots is that I can just bring it back online and it will be the same as when I shut it down.

So after I generated my SSH key in Termux and uploaded it to my cloud provider, I recreated the virtual machine and SSH-ed in, and viola, a perfectly usable, and powerful, development machine.

Termux SSH Views of Cloud Virtual Machine

How My Cloud Development Machine Looks In Termux On My Android Device

or is it?

There Is Always A But

I'm not going to lie to you and say that this was a perfect experience and that everyone should be coding on their phones. No no no, this was by far the worst experience short of using punched cards and a single-key keyboard to type in Morse code, plus at least those would be kind of fun.

Between the small screen real estate (without an external keyboard) and constant context-switching, it can be insufferable to work on for most people, me included. If I were to do it again though, a wireless keyboard would definitely help here.

Takeaways

If it's such a bad experience, why am I recommending it?

I would not say recommending but more so showing readers who have not explored the capabilities of their everyday devices that programming is possible on a wide array of electronics and not just a powerful desktop machine. In addition, I want this to be a motivation that you can, in fact, program on the go if you put your mind to it.

Afterwords

Next time I'll program on top of Everest or something

That's it!

Follow or reach out to me on Twitter @justinhodev for my daily coding titbits!

If you're interested in the project I'm working on, here is the repository:

GitHub logo jcsho / hype-tracker

Full stack web application to read data from public APIs (Twitter, Reddit) and form visualizations

HypeTracker

Current Version Codacy Badge StyleCI License FOSSA Status


HypeTracker is a data aggregator application for social media 'impressions' on sneakers bought and sold in the aftermarket.

See my blog detailing what HypeTracker is and why I am refactoring it

Changelog / Goals for V2

  • migrate database schema see PR #4
  • migrate internal sneakers API see PR #7
  • migrate front-end see PR #17
  • deploy as demo / push as v2
  • add social media api scraping

Getting Started

Requirements

Homestead

  • PHP ^7.3
  • Composer ^1.10.13
  • Vagrant ^2.2.10 (with your choice of virtualization layer)
  • (example) VirtualBox ^6.1.14 (with Vagrant's VirtualBox provider)
$ git clone https://github.com/justinhodev/hype-tracker.git
$ cd hype-tracker

# Install Composer Dependencies
$ composer install

# Prepare config for Homestead
$ composer homestead

# Provision the VM
$ vagrant up

# SSH into Vagrant Box
$ vagrant ssh
Enter fullscreen mode Exit fullscreen mode

Docker

coming soon

Database Entity Relationship Model

ER Diagram

License

FOSSA Status




Discussion (0)