nanodano's blog

Advertisement

Advertisement

Get Directory of Current .py File

When writing a Python application sometimes it can be useful to get the name of the Python file where the code is stored. To take it further, you might want to get the full absolute path of the Python file or just the directory of the Python file. This can be particularly useful if you want to reference resources relative to the Python file, wherever it may reside.

SQLite3 Tutorial

SQLite3 is an ubiquitous relational database written in C. The main thing that stands out about SQLite versus other databases is the fact that the whole database is contained in a single file with no server or configuration needed making it very easy to set up and use. It is licensed as public domain which is even more free than typical open source libraries like MIT or GPL. It uses a mostly SQL compliant language so if you are familiar with any other standard SQL engine the language should be something you are familiar with.

Ruby SQLite Tutorial

SQLite3 is an awesome cross-platform relational database. Some of the major benefits of SQLite include its simplicity and easy management. Everything is stored in a single file and there is no authentication.

One of the big drawbacks with a SQLite database is that there is a global write-lock. Only one write operation can occur at any time. This can create a bottleneck for very write-intensive applications.

SQLite is used in production in many embedded and web applications. For example, you can use SQLite in combination with the Sinatra web application framework to persist data. If you are interested in learning how to use Sinatra, check out my Sinatra Tutorial.

Ruby is an incredibly productive and useful language. Combining Ruby with SQLite3 is a natural fit that opens many possibilities. Add in a simple web framework like Sinatra and you have an incredibly powerful but simple set of tools for building a web application.

You can read more on the official SQLite3 website and on the SQLite Wikipedia article.

If you need a database-agnostic library, something that you can use with SQLite and then easily configure to start using MySQL without rewriting all of your code, you want to use an ORM. ORM stands for Object-Relational-Mapping and the most popular one for Ruby is ActiveRecord.

Ruby Sinatra Tutorial

Sinatra is a minimalist web framework for the Ruby programming language. It is known for being very simple and easy to use. If you are familiar with express.js, it was inspired by Sinatra. I have found it to be incredibly useful and fast to work with. This tutorial will cover some of the common tasks that I have used.

Deploy Ruby Rack Web Apps with uWSGI and Nginx

This tutorial demonstrates how to deploy a Ruby web app using the Sinatra framework using uWSGI and nginx as the web server. This uses the config.ru standard for creating a web app. You can use this method to work with several other Ruby web frameworks including Rails.

This was tested on Fedora 30. Slight modification might be needed for other distributions.

How to Verify a Checksum

A checksum is a special type of hash that is used to verify the integrity of a file. Verifying a checksum ensures there was no corruption or manipulation during the download and the file was downloaded completely and correctly.

A common use case for checksum verification is to verify a large download like an .iso disk image. MD5 and SHA1 hashes are commonly used for this task. We will look at easy ways to obtain a hash to verify a checksum.

How to Verify a GPG Signature

This tutorial covers the process of verifying a GPG signature, which is commonly done to verify the authenticity of a email, document, or downloaded file to ensure it came from the expected source. This only covers verifying signature and not creating them. To learn how to sign and how to sign-and-encrypt, read GPG Tutorial - Signatures.

GPG offers a lot more functionality than just verifying signatures though. To learn more about GPG in general and how to manage keys, encrypt, sign, and more, read my GPG Tutorial.

Advertisement

Advertisement