It’s always fun to put your Android or Python programming skills on display. A while back, I figured it’d be cool to try and control my laptop via my Android mobile device. Think about it: remote laptop access including being able to play and pause music, start and stop programming jobs or downloads, etc., all by sending messages from your phone. Neat, huh?
Before you keep on reading, please bear in mind that this is a pet project, still in its early stages—but the basic platform is there. By gluing together some mainstream tools, I was able to setup my Android phone to control my laptop via a Python interpreter.
By the way: the project is open source. You can check out the client code here, and the server code here.
This project involves the following technologies, some of which you may be familiar with, some of which are quite specific to the task at-hand:
- Python 2.7+
- Twisted: an excellent event-driven framework especially crafted for network hackers.
- Django: I used v1.4, so you’ll have to adjust the location of some files if you want to run a lower version.
- Amarok: a D-BUS (more on this below) manageable media player. This could be subbed out for other such media players (Clementine, VLC, or anything that supports MPRIS) if you know their messaging structures. I chose Amarok because it comes with my KDE distribution by default. Plus, it’s fast and easily configurable.
- An Android phone with Python for Android installed (more on this below). The process is pretty straightforward—even for Py3k!
- Remote Amarok and Remote Amarok Web.
At a High Level
At a high level, we consider our Android phone to be the client and our laptop, the server. I’ll go through this remote access architecture in-depth below, but the basic flow of the project is as follows:
- The user types some command into the Python interpreter.
- The command is sent to the Django instance.
- Django then passes the command along to Twisted.
- Twisted then parses the command sends a new command via D-Bus to Amarok.
- Amarok interacts with the actual laptop, controlling the playing/pausing of music.
Now, lets dig in.
Continue reading Control Your Laptop with an Android Phone using Python, Twisted, and Django
We’ve all been there. You’re working on the API back-end, and you’re happy with how it’s going. You’ve recently completed the minimal viable product (MVP), the tests are all passing, and you’re looking forward to implementing some new features.
Then the boss sends you an email: “By the way, we need to let people log in via Facebook and Google; they shouldn’t have to create an account just for a little site like ours.”
Great. Scope creep strikes again.
The good news is that OAuth 2 has emerged as the industry standard for social and third-party authentication (used by services such as Facebook, Google, etc.) so you can focus on understanding and implementing that standard to support a wide range of social authentication providers.
It’s likely you’re not familiar with OAuth 2; I wasn’t, when this happened to me.
Continue reading How to Integrate OAuth 2 Into Your Django/DRF Back-end Without Going Insane
Though many Django Developers might consider it blasphemous, sometimes it is actually necessary to deploy Django applications on Windows/IIS, especially when working with a client that has based its infrastructure around the Windows ecosystem. The “blasphemy” part comes from Django having really been targeted at the Unix environment, relying heavily on features like WSGI, FastCGI, and command-line tooling, all of which are foreign to Windows. Fortunately, Django/IIS compatibility is improving, thanks to the addition of features (which would otherwise be a kludge) on both the Windows and the Python+Django sides of the equation, thereby helping to resolve compatibility issues between these two disparate technical worlds.
Continue reading Installing Django on IIS: A Step-by-Step Tutorial
Deploy Python Django app in heroku cloud
PostgreSQL needed since heroku don’t support sqlite3
install pgsql supports(not really required to install in your local but add in requirement.txt)
pip install dj-database-url gunicorn whitenoise psycopg2
pip freeze > requirements.txt
Somehow psycopg2 not installing in my local but I added psycopg2 in requirements.txt
Continue reading Deploy Django in Heroku