Skip to content

Instantly share code, notes, and snippets.

@barbietunnie
barbietunnie / ansible-variable-precedence.md
Last active March 19, 2023 20:25
Ansible Variable Precedence

Ansible Variable Precedence

Here is the order of precedence from least to greatest (the last listed variables override all other variables):

  1. command line values (for example, -u my_user, these are not variables)
  2. role defaults (defined in role/defaults/main.yml) [1]
  3. inventory file or script group vars [2]
  4. inventory group_vars/all [3]
  5. playbook group_vars/all [3]
  6. inventory group_vars/* [3]
@barbietunnie
barbietunnie / config.py
Last active December 7, 2022 00:11
Working with relative paths in Python
import os
ROOT_DIR = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
@barbietunnie
barbietunnie / nginx-headers-underscore.md
Created December 6, 2022 04:10
How to fix – NGINX not accepting headers with underscore

How to fix – Nginx not accepting headers with underscore

Although headers with underscore are perfectly valid according to HTTP standards, however NGINX does not support it by default. To enable NGINX to accept headers with underscore, add the following directive within the server block of your NGINX configuration.

underscores_in_headers on;

Validate and reload the configuration after making this change as follows:

@barbietunnie
barbietunnie / user-group-daemon.md
Created December 6, 2022 02:43
How to determine the user and group of a daemon in Ubuntu

How to determine the user and group of a daemon in Ubuntu

The situation occasionally arises when you need to determine the user and group a daemon such as nginx is running as on Ubuntu, you can basically run the following command:

ps aux|grep nginx|grep -v grep
@barbietunnie
barbietunnie / django-secret-key.py
Created December 5, 2022 04:06
How to generate a Django `SECRET_KEY`
from django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
@barbietunnie
barbietunnie / file-contents-dump-ansible.md
Created November 25, 2022 12:09
How to dump file contents to console with Ansible

How to dump file contents to console with Ansible

-  name: Display content of resolv.conf
  hosts: localhost
  tasks:
    - name: Display resolv.conf contents
      command: cat resolv.conf chdir=/etc
      register: command_output
@barbietunnie
barbietunnie / custom-fonts-taliwindcss-nextjs.md
Last active February 25, 2025 06:51
How to Use Custom Fonts in TailwindCSS + NextJS

How to Use Custom Fonts in TailwindCSS + NextJS

Assuming your have already set up your NextJS + Tailwind project,

1. Select your desired custom Google font

2. Scroll to the bottom and select all the styles you are interested in

Select all your desired styles

@barbietunnie
barbietunnie / restart-postgres-centos.md
Created November 10, 2022 11:21
Restart Postgres on Cent OS 7

Restart Postgres on Cent OS 7

  1. Get the service name

    sudo systemctl list-units | grep postgresql
    
  2. Restart the service

@barbietunnie
barbietunnie / tilde-vs-caret-differences.md
Created November 10, 2022 11:03
Difference between tilde(~) and caret(^) in package.json

Difference between tilde(~) and caret(^) in package.json

According the NPM and semver docs,

  • ~version - "Approximately equivalent to version", see semver.

    It does not increment the minor version

For example,

@barbietunnie
barbietunnie / manage-shell-history.md
Last active November 6, 2022 10:33
Managing shell history with `historian`

Managing shell history with historian

historian is a command-line utility for managing shell history using an SQLite database.

~/.bash_history is deduped and imported into a database.

Setup

  1. Add to PATH