[Note] [Lifestyle] FireFox on Linux + Django + Nginx = 499 ERROR omfg

I spent 6 hours today in Nginx configurations and logs, I learnt so much about Nginx and devops process. And in the end it was all because FireFox browser (I use desktop Ubuntu on my laptop) refused to connect to the server and get the sweet HTML pages I tried to serve it.

In particular, when I renounced attempts to serve HTML pages with explicitly stated location tags and launched my good old trusted Django and it STILL didn’t work (I got 499/403 in the access.log and 404 in the browser), I came to thinking something evil is going on here. It was an unexpected, and a bad one.

The moment I opened it in Google Chrome and it worked, dudes, if I was standing, I would fall that moment on my butt.

I immediately wrote to my Python friends "screw web, I will do webcam now". But, it was a rushed thought I soon gave up. Thankfully, I did not write that to my boss.

[Note] ‘ChatConsumer’ has no attribute ‘as_asgi’ – Sloppy development

Following Channels’ docs I encountered yet another error the solution to what was not obvious right off the bat.

Ditch Channels.

The End.

This was my original post in October 2020 and I stand by it.

You can make your project work with Google Firebase - it handles signals well enough. Yes it is primarily used by mobile developers, but overall it is fine for web too.

I spent trying to install Django Channels on my local Linux 18.04, and I kind of made it work, but then I had to deploy it... And as a professional backender you don't want to let people down.

I decided to try Channels because my Python-related friends talked about it. But days into the trouble I asked my friend about a certain step and he asked me in return "oh so [you use it because] they fixed Channels since two years ago?". I as like ??????????????????. So that moment I ditched it. Too much time wasted, but I like the result I achieved with Firebase.

What I am saying - Firebase is fast and universal. In a matter of days I managed to make and deploy an internal Customer Support chat service that connected mobile app users and a support from the web.</p>

I will be writing a new series on Django + Firebase, and this post is pretty much a short introduction.

ffmpeg: Non-monotonous DTS in output stream 0:0 – Video Generation Series (Part 2) [ERROR]

This error occured when I used ffmpeg to concatenate different videos that I generated:

ffmpeg -f concat -safe 0 -i list.txt -c copy final_video.avi -y
BTW, if you want to run ffmpeg or any other command inside a python script (a very reasonable idea), use subprocess:

command = "ffmpeg -f concat -safe 0 -i list.txt -c copy final_video.avi -y"
subprocess.Popen(command.split(), stdout=subprocess.PIPE)

As a result – the videos got smashed together – some frames even never appeared.

Read More »

Make a JSON from PostgreSQL table (for Django)

First, choose a folder you want to copy the table to and grant postgres user access to it. I chose /home:

sudo chown -R postgres:postgres /home

Then log into postgres user:

sudo su - postgres

Then get to your database. If it is a Django project, you can find the name in settings.py:

psql dbname

Then, if you need your app’s tables, make a table name from these components:

{{ app_name }}_{{ model_name }}

For app userapp and model User, I have userapp_user. So in a /home/users.json I want to copy:

\t
\a
\o /home/users.json
SELECT row_to_json(r) FROM userapp_user AS r;

That’s it.

Transitioning to IOS Development

I believe it is important to listen to yourself and sense if something rubs you wrong. It’s not that I hate backend, I just don’t see myself growing. My preference is to live and work independently, and at this point, with my education and personal predisposition I am inclined to try Mobile development as a career path. I deem my experience in Django and Web development in general (including UI/UX) will help me thrive further.

By no means I am quitting this blog. I am not quitting Django either. If anything, I want to leave myself an opportunity to work as a Full-stack developer in both Web and Mobile development.

Why IOS and now Android? At least for now, I have 0 Android devices and a lot of IOS ones 🙂

I will do blog posts about the transition, and not just from back-end to mobile front-end, but from Python to Swift.

I am adding two more sections – Swift and Career.