CPU Usage Percent – Python One-Liner for Load Average per CPU

Processor usage is 88%. But how do I get a number like this? For gurus, this Python one-liner prints CPU usage $ python3 -c “print(‘{:.0f}%’.format( float(‘$(cat /proc/loadavg)’.split()[0]) / float(‘$(nproc)’)*100 ) )” 12% The rest of us can read on how … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , | Comments Off on CPU Usage Percent – Python One-Liner for Load Average per CPU

Vulnerable Super Secure Password Recover – SQL Injection Example

Can you exploit OWASP #1 vulnerability? I wrote a simple vulnerable password recovery app for practicing SQL injections. (Vulnerable) Super Secure Password Recover ™ is written with Python 3, Flask and Postgres. You can do bad code even with the … Continue reading

Posted in Uncategorized | Tagged , , , , | Comments Off on Vulnerable Super Secure Password Recover – SQL Injection Example

pydoc3 str – Python Reference in Your Command Line – Airplane & Cottage Entertainment

You can read Python documentation offline with pydoc3. It’s installed automatically with Python, and it always shows documentation for the version of Python you have installed. $ pydoc3 str You can see reference for a library ‘pydoc3 re’ or a single … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , | Comments Off on pydoc3 str – Python Reference in Your Command Line – Airplane & Cottage Entertainment

Python RegEx One-Liner in a Pipe – Remove Hard Line Wrapping – No Perl

Just put Python in your pipe and let Perl rest in peace. Python can be used as a one-liner in a pipe. Replacing text with a regular expression used to be the last holdout of perl, but now you can … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , | Comments Off on Python RegEx One-Liner in a Pipe – Remove Hard Line Wrapping – No Perl

Hello Flask Web App – Python 3 Flask Development Server Install on Ubuntu 16.04

You can create web apps with Python and Flask. This short “Hello World” tutorial shows you how to install development server for Python 3 and Flask. There are two very successful Python web frameworks. Flask is the simple one, Django … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , | 1 Comment

Using Web APIs with Python – Read Weather Forecast and Send to Your Own IoT Device

Do you want get weather forecast, BitCoin vs EUR valuation and know your power consumption? A lot of data is available on free APIs. Your program can just make a regular HTTP GET request – it’s just like loading a … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , , | Comments Off on Using Web APIs with Python – Read Weather Forecast and Send to Your Own IoT Device

Django on Apache – with Python 3 and Apache mod_wsgi on Ubuntu 16.04

Install Python 3 Django on Apache, similar to production installations. These terse notes show how to install Python Django, configure it to use templates and access PostgreSQL database. Finally, we create a simple app to read records from database and … Continue reading

Posted in Uncategorized | Tagged , , , , , , | Comments Off on Django on Apache – with Python 3 and Apache mod_wsgi on Ubuntu 16.04

Write Python 3 Web Apps with Apache2 mod_wsgi – Install Ubuntu 16.04 xenial – Every Tiny Part Tested Separately

Python is a popular language for web applications, used by Youtube, DropBox, Facebook, Pintrest, Reddit, Instagram, Spotify, Washington Post and many others. Apache is the most popular web server in the world. Mod_wsgi is the recommended way to use Python … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , | 3 Comments

Install OpenAI Universe on Ubuntu 16.04

OpenAI: Write Python program that plays any game. Optionally, use machine learning so that computer learns the game by itself. OpenAI “hello world” is just ten lines. But installing the environment is difficult. This article shows you how to install … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , , , , , , | 5 Comments

Deploy Flask & Python3 on Apache2 & Ubuntu

Deploy Flask, a Python 3 microframework, on Apache web server on Ubuntu. Then you can write your own web pages in Python. Flask is a very simple framework for writing server side applications with Python. This article shows how to … Continue reading

Posted in Uncategorized | Tagged , , , , , , , , , , , , , , | 13 Comments