From 6ced3a0d05166213729a22f2aee93b42e8b66c9c Mon Sep 17 00:00:00 2001 From: Ian Andwati Date: Sat, 22 Apr 2023 21:41:07 +0300 Subject: [PATCH] publish site --- README.md | 1 + config.yml | 2 +- content/about.md | 2 - .../november/generate-django-secret-key.md | 69 ++++++ content/post/2022/november/hello-world.md | 2 +- ...mantic-version-and-conventional-commits.md | 117 +++++++++++ ...tgresql-15-on-arch-manjaro-garuda-linux.md | 0 ...tgresql-15-on-arch-manjaro-garuda-linux.md | 196 ++++++++++++++++++ netlify.toml | 33 +++ 9 files changed, 418 insertions(+), 4 deletions(-) create mode 100644 README.md create mode 100644 content/post/2022/november/generate-django-secret-key.md create mode 100644 content/post/2022/november/semantic-version-and-conventional-commits.md delete mode 100644 content/post/2023/feb/install-postgresql-15-on-arch-manjaro-garuda-linux.md create mode 100644 content/post/2023/february/install-postgresql-15-on-arch-manjaro-garuda-linux.md create mode 100644 netlify.toml diff --git a/README.md b/README.md new file mode 100644 index 0000000..715c028 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +# Personal site revamped diff --git a/config.yml b/config.yml index 1672bfc..0f34a96 100644 --- a/config.yml +++ b/config.yml @@ -114,7 +114,7 @@ menu: weight: 20 - identifier: newsletter name: newsletter - url: https://example.org + url: https://buttondown.email/andwati weight: 30 - identifier: about name: about diff --git a/content/about.md b/content/about.md index 148bee3..b1bf85f 100644 --- a/content/about.md +++ b/content/about.md @@ -30,5 +30,3 @@ My ultimate goal is to work on challenging projects that push the boundaries of - Twitter : https://twitter.com/andwati_ - Email : andwatiian@gmail.com - -- [Get my resume](https://drive.google.com/file/d/1VxtowA5ZMNP52bMSwEtQLNidgDQvKY3Z/view?usp=sharing) diff --git a/content/post/2022/november/generate-django-secret-key.md b/content/post/2022/november/generate-django-secret-key.md new file mode 100644 index 0000000..a3c5bed --- /dev/null +++ b/content/post/2022/november/generate-django-secret-key.md @@ -0,0 +1,69 @@ +--- +title: "Django Secret Key Tutorial" +date: 2022-11-11T15:34:14.160Z +# weight: 1 +# aliases: ["/first"] +tags: ["tutorial", "Django", "Python", ".emv"] +author: "Ian Andwati" +showToc: true +TocOpen: false +draft: false +hidemeta: false +comments: false +description: "django secret key tutorial" +canonicalURL: "" +disableHLJS: true # to disable highlightjs +disableShare: false +disableHLJS: false +hideSummary: false +searchHidden: true +ShowReadingTime: true +ShowBreadCrumbs: true +ShowPostNavLinks: true +ShowWordCount: true +ShowRssButtonInSectionTermList: true +UseHugoToc: true +cover: + image: "" # image path/url + alt: "" # alt text + caption: "" # display caption under cover + relative: false # when using page bundles set this to true + hidden: true # only hide on current single page +editPost: + URL: "https://github.com/andwati/content" + Text: "Suggest Changes" # edit text + appendFilePath: true # to append file path to Edit link +--- + +Managing the Django SECRET_KEY variable. + + + +The Django `SECRET_KEY` variable is very crucial to your Django application. The secret key must be a large random value and it must be kept secret. Leaking this value to unauthorized people could lead to a security breach. The SECRET_KEY is used in Django for cryptographic signing. It is used to generate tokens and hashes, they can be recreated using this variable. If it is not configured Django throws a `django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty` error + +# Using Environment Variables + +The secret key should not be committed to version control. It is best practice to store the value in a .env file which is added to the .gitignore file to un-track its changes. The values can be loaded programmatically into your settings.py file. + +# Generating A New Secret Key + +This solution is using python's secrets lib on the back + +```python +from django.core.management.utils import get_random_secret_key +# print new random secret key +print(get_random_secret_key()) +``` + +This code can be run in the terminal as a command: + +```python +python -c 'from django.core.management.utils import get_random_secret_key; \ + print(get_random_secret_key())' +``` + +Alternatively, If you are using python 3.6+ then you can use the `secrets.token_hex(\[nbytes=None])` function: + +```python +python3 -c 'import secrets; print(secrets.token_hex(100))' +``` diff --git a/content/post/2022/november/hello-world.md b/content/post/2022/november/hello-world.md index 26a24ea..cff96ea 100644 --- a/content/post/2022/november/hello-world.md +++ b/content/post/2022/november/hello-world.md @@ -8,7 +8,7 @@ TocOpen: false draft: false hidemeta: false comments: false -description: "Integrating netlify cms." +description: "Hello world" canonicalURL: "" disableHLJS: true # to disable highlightjs disableShare: false diff --git a/content/post/2022/november/semantic-version-and-conventional-commits.md b/content/post/2022/november/semantic-version-and-conventional-commits.md new file mode 100644 index 0000000..b934c95 --- /dev/null +++ b/content/post/2022/november/semantic-version-and-conventional-commits.md @@ -0,0 +1,117 @@ +--- +title: "Semantic Versioning(SemVer) and Conventional Commits" +date: 2023-01-24T15:34:14.160Z +# weight: 1 +# aliases: ["/first"] +tags: ["git", "semver","workflow", "conventional commits"] +author: "Ian Andwati" +showToc: true +TocOpen: false +draft: false +hidemeta: false +comments: false +description: "semantic versioning" +canonicalURL: "" +disableHLJS: true # to disable highlightjs +disableShare: false +disableHLJS: false +hideSummary: false +searchHidden: true +ShowReadingTime: true +ShowBreadCrumbs: true +ShowPostNavLinks: true +ShowWordCount: true +ShowRssButtonInSectionTermList: true +UseHugoToc: true +cover: + image: "" # image path/url + alt: "" # alt text + caption: "" # display caption under cover + relative: false # when using page bundles set this to true + hidden: true # only hide on current single page +editPost: + URL: "https://github.com/andwati/content" + Text: "Suggest Changes" # edit text + appendFilePath: true # to append file path to Edit link +--- + +Adopting best practices in your git and build workflows. + + + +# What is Semver? + +Semantic versioning or just SemVer is a dependency naming guidline that aims to bring some sanity into naming libraries and packages in software development. It is a standard versioning system created by **Tom Preston Werner** (co-founder of Github) that’s used to communicate what changes are in a release. + +An efficient and smooth versioning becomes crucial for efficient software delivery expecially for projects that expose a public API. This saves the developers the chaos that is **dependency hell**.Dependency hell is a colloquial term for the frustration of some software users who have installed software packages which have dependencies on specific versions of other software packages. + +The dependency issue arises when several packages have dependencies on the same shared packages or libraries, but they depend on different and incompatible versions of the shared packages. If the shared package or library can only be installed in a single version, the user may need to address the problem by obtaining newer or older versions of the dependent packages. This, in turn, may break other dependencies and push the problem to another set of packages. + +## Semantic Versioning Specifications + +### Summary + +Semantic versioning is based on three numbers that indicate the versions of the software and the compatibilities.They are `X.Y.Z` correspondind to `Major.Minor.Patch` + +- **Major Version (X):**Introduces major changes to the code and breaking changes toward backward compatibility +- **Minor Version (Y):** These code changes don’t introduce breaking changes. This could be adding a new feature that doesn't break changes but are not exactly bug fixes. +- **Patches (Z):** Mainly correspond to bug fixes + +### Examples in common packages + +#### React(v18.2.0) + +![react](/images/uploads/react.png "React versioning") + +- **Major -> 18** +- **Minor -> 2** +- **Patch -> 0** + +--- + +#### Pipx(v1.1.0) + +![](/images/uploads/pipx.png) + +- **Major -> 1** +- **Minor -> 1** +- **Patch -> 0** + +--- + +## Start at v0.1.0 or v1.0.0? + +Convention recommends that in the initial development phase the starting version should be 0.1.0 which makes sense since it’s not in production yet. + +The version should only be bumped to 1.0.0 only if it is being used in production and stable. + +If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0. + +# Conventional Commits + +Conventional Commits is a convention on top of commit messages that are used to automate version changes. It provides an easy set of rules for creating commit messages and works well with SemVer by describing features, fixes and breaking changes that correspond to SemVer standards. + +## Summary + +The commit message should be structured as follows: + +``` +[optional scope]: + +[optional body] + +[optional footer(s)] +``` + +The commit contains the following structural elements, to communicate intent to the consumers of your library: + +1. fix: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning). +2. feat: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning). +3. BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type. +4. types other than fix: and feat: are allowed, for example @commitlint/config-conventional (based on the Angular convention) recommends build:, chore:, ci:, docs:, style:, refactor:, perf:, test:, and others. +5. footers other than BREAKING CHANGE: may be provided and follow a convention similar to git trailer format. + +# Resources + +https://semver.org/ +https://www.conventionalcommits.org/en/v1.0.0/ diff --git a/content/post/2023/feb/install-postgresql-15-on-arch-manjaro-garuda-linux.md b/content/post/2023/feb/install-postgresql-15-on-arch-manjaro-garuda-linux.md deleted file mode 100644 index e69de29..0000000 diff --git a/content/post/2023/february/install-postgresql-15-on-arch-manjaro-garuda-linux.md b/content/post/2023/february/install-postgresql-15-on-arch-manjaro-garuda-linux.md new file mode 100644 index 0000000..13b4fc6 --- /dev/null +++ b/content/post/2023/february/install-postgresql-15-on-arch-manjaro-garuda-linux.md @@ -0,0 +1,196 @@ +--- +title: "Install PostgreSQL 15 on Arch | Manjaro | Garuda Linux" +date: 2023-02-16T15:34:14.160Z +# weight: 1 +# aliases: ["/first"] +tags: ["postgresql", "archlinux", "manjaro","garuda","linux"] +author: "Ian Andwati" +showToc: true +TocOpen: false +draft: false +hidemeta: false +comments: false +description: "Integrating netlify cms." +canonicalURL: "" +disableHLJS: true # to disable highlightjs +disableShare: false +disableHLJS: false +hideSummary: false +searchHidden: true +ShowReadingTime: true +ShowBreadCrumbs: true +ShowPostNavLinks: true +ShowWordCount: true +ShowRssButtonInSectionTermList: true +UseHugoToc: true +cover: + image: "" # image path/url + alt: "" # alt text + caption: "" # display caption under cover + relative: false # when using page bundles set this to true + hidden: true # only hide on current single page +editPost: + URL: "https://github.com/andwati/content" + Text: "Suggest Changes" # edit text + appendFilePath: true # to append file path to Edit link +--- + +Getting PostgreSQL up and running on Arch Linux-based distros + + + +# Overview + +**PostgreSQL** is a powerful open-source relational database management system (RDBMS) that allows you to store and manage large amounts of data. It was first released in 1996 and has become one of the most popular RDBMSs in the world. + +PostgreSQL is designed to handle high levels of **concurrency**, providing features such as **MVCC (multi-version concurrency control)** that allow multiple users to access the same data simultaneously without conflicts. It is also **highly extensible**, with a large number of third-party extensions and libraries available that can be used to add functionality to the core database. + +Some of the key features of PostgreSQL include support for **complex SQL queries**, **advanced indexing** and **query optimization**, **transactional integrity**, and support for a **wide range of programming languages** and development frameworks.PostgreSQL is used by a wide range of organizations, from small businesses to large enterprises, and is particularly popular in industries such as finance, healthcare, and e-commerce, where high levels of data security and reliability are critical. + +In this tutorial, we’ll look at how to install PostgreSQL 15 on Arch Linux, Manjaro, Garuda Linux, or any other Arch-based distro out there. + +# PostgreSQL use cases + +- **E-commerce websites:** PostgreSQL is a popular choice for e-commerce websites because it can handle large amounts of data and supports complex queries. It is used for product catalogs, order management, customer data, and more. +- **Financial institutions:** PostgreSQL is used in financial institutions to store and manage transactional data, such as stock trades, bank transfers, and credit card transactions. It is highly secure and provides features such as transactional integrity and data encryption. +- **Healthcare industry:** PostgreSQL is used in the healthcare industry to store patient data, such as medical records and diagnostic test results. It is also used for research purposes, where large amounts of data need to be stored and analyzed. +- **Government agencies:** PostgreSQL is used by government agencies for a variety of purposes, including managing large datasets, storing and analyzing census data, and managing public health information. +- **Mobile and web applications:** PostgreSQL is often used as a back-end database for mobile and web applications. It provides reliable data storage and retrieval and supports a wide range of programming languages and development frameworks. +- **Geospatial applications:** PostgreSQL has built-in support for geospatial data and is often used for applications that require location-based data, such as mapping and GPS tracking. + +# Why PostgreSQL? + +Postgres offers a lot of advantages that make it an excellent choice for highly transactional environments regardless of application size and data volume. Its rich feature set and flexibility make it a popular choice for a wide range of applications and industries. Some of the top features are: + +- **ACID Compliance:** PostgreSQL is ACID (Atomicity, Consistency, Isolation, Durability) compliant, which means it provides high reliability, consistency, and data integrity, even in the presence of hardware failures, power outages, and other system errors. +- **Extensibility:** PostgreSQL is highly extensible, allowing developers to add new data types, operators, and functions using its extension framework. This makes it easy to customize PostgreSQL to meet the specific needs of your application. +- **Concurrency:** PostgreSQL provides a high level of concurrency, allowing multiple users to access the same data at the same time without conflicts. It uses a Multi-Version Concurrency Control (MVCC) model that enables fast and reliable access to data, even under heavy load. +- **Full-text search:** PostgreSQL provides a powerful full-text search engine that supports advanced search capabilities, such as stemming, ranking, and relevance matching. +- **Advanced indexing:** PostgreSQL provides a wide range of indexing options, including B-tree, Hash, GiST, SP-GiST, GIN, and BRIN. These indexing options allow developers to optimize database performance for their specific use cases. +- **JSON support:** PostgreSQL provides native support for storing and querying JSON data, making it easy to work with modern web and mobile applications that rely on JSON for data exchange. +- **Security:** PostgreSQL provides a high level of security, with features such as SSL support, client authentication, and role-based access control. It also provides encryption for both data at rest and data in transit. +- **Scalability:** PostgreSQL is designed to scale horizontally and vertically, allowing you to add more nodes to a cluster or increase the resources of a single node to handle more load. + +# Install PostgreSQL on Arch | Manjaro | Garuda Linux + +Now with all that fluff out of the way, let's get to business. The steps have been tested on Arch Linux with the KDE desktop. + +> **Note:** Commands that should be run as the *postgres* user are prefixed by `[postgres]$` in this article. + +## Step 1: Installing the PostgreSQL Package + +```shell +$ sudo pacman -Syu postgresql +``` + +This command will update the package database and update all packages on the system then install the PostgreSQL package from your distribution mirrors. Never install a package without updating the system first. On a rolling release, this can lead to an unbootable system. Installing the package will also create a system user called *postgres*. You can now switch to the *postgres* user using a privilege elevation program. + +You can switch to the PostgreSQL user by executing the following command: + +- If you have sudo and are in sudoers + + ```shell + $ sudo -iu postgres + ``` + +- Otherwise using su: + + ```shell + $ su + # su -l postgres + ``` + +## Step 2: Initial Configuration + +Before PostgreSQL can function correctly, the database cluster must be initialized. + +### 2.1 We can confirm the installed PostgreSQL version by running: + +```shell +$ postgres --version ─╯ +postgres (PostgreSQL) 15.1 +``` + +### 2.2 Set applicable entries in **/etc/locale.gen** + +```shell +$ echo "en_US.UTF-8 UTF-8" | sudo tee /etc/locale.gen +``` + +### 2.3 Then run **\*\*locale-gen\*\*** to generate locale settings + +```shell +$ sudo locale-gen +Generating locales... + en_US.UTF-8... done +Generation complete. +``` + +### 2.4 Initialize Postgres Data Directory + +You must first log in as the **postgres** user using the following command before you can initialize PostgreSQL’s data directory: + +```shell +sudo su - postgres +``` + +### 2.5 With the following command, you can now initialize PostgreSQL’s data directory: + +```shell +[postgres]$ initdb -D /var/lib/postgres/data +``` + +### Step 3: PostgreSQL Service Management + +### 3.1 Check PostgreSQL status with the following command: + +```shell +$ systemctl status postgresql ─╯ + postgresql.service - PostgreSQL database server + Loaded: loaded (/usr/lib/systemd/system/postgresql.service; disabled; preset: disabled) + Active: inactive (dead) +``` + +### 3.2 Start the PostgreSQL service by running the following command: + +```shell +sudo systemctl start postgresql +``` + +### 3.3 Enable the PostgreSQL service to start automatically at boot by running the following command: + +```shell +$ sudo systemctl enable postgresql +``` + +### 3.4 Verify that PostgreSQL is running by running the following command: + +```shell +$ sudo systemctl status postgresql ─╯ +● postgresql.service - PostgreSQL database server + Loaded: loaded (/usr/lib/systemd/system/postgresql.service; enabled; preset: disabled) + Active: active (running) since Thu 2023-02-16 22:52:43 EAT; 20s ago + Main PID: 26106 (postgres) + Tasks: 6 (limit: 8790) + Memory: 16.9M + CPU: 113ms + CGroup: /system.slice/postgresql.service + ├─26106 /usr/bin/postgres -D /var/lib/postgres/data + ├─26107 "postgres: checkpointer " + ├─26108 "postgres: background writer " + ├─26110 "postgres: walwriter " + ├─26111 "postgres: autovacuum launcher " + └─26112 "postgres: logical replication launcher " +``` + +# Resources + +- [Arch Linux Wiki](https://wiki.archlinux.org/title/PostgreSQL) +- [Wikipedia](https://en.wikipedia.org/wiki/PostgreSQL) +- [PostgreSQL Documentation](https://www.postgresql.org/docs/) + +# Conclusion + +Installing PostgreSQL on Arch Linux-based distribution is a straightforward process that can be completed in just a few steps. By following the steps outlined above, you can install, configure, and start the PostgreSQL database server on your Arch Linux system. Once installed, you can use PostgreSQL to store, manage, and query data for a wide range of applications and use cases. With its advanced features and high level of extensibility, PostgreSQL is a popular choice for developers and businesses seeking a robust and reliable database management system. + +You can connect to the PostgreSQL server using the psql command-line client or a graphical tool such as pgAdmin. diff --git a/netlify.toml b/netlify.toml new file mode 100644 index 0000000..c5c5f6d --- /dev/null +++ b/netlify.toml @@ -0,0 +1,33 @@ +[build] +command = "hugo" +publish = "public" + +[build.environment] +HUGO_VERSION = "0.111.3" + +[build.processing] +skip_processing = false + +[build.processing.css] +bundle = true +minify = false + +[build.processing.js] +bundle = true +minify = false + +[build.processing.html] +pretty_urls = true + +[build.processing.images] +compress = true + +[[headers]] +for = "/*" +[headers.values] +Cache-Control = "public, max-age=600" + +[[headers]] +for = "*.(css|js|woff|woff2|ttf|png|jpg|jpeg)" +[headers.values] +Cache-Control = "public, max-age=2592000"