An easy to get an API up and running for a Proof of Concept (POC) or a Minimal Viable Product (MVP) is to put PostgREST in front on your Database.
Continue readingLaunch a simple HTTP Server in One Line of Python
python3 -m http.server 8080 -d ./public
Types of UUID
- v1: mac address + time + random
- v4: completely random
- v5: input + seed (consistent, derived from input)
- v7: time + random (distributed sortable ids)
Ubuntu Desktop personal setup
This is how I customize a clean Ubuntu install.
Essentials
First we install the essentials.
- curl
- vim
- fish shell
- tmux
- git
- xclip
sudo apt install curl vim fish tmux
SSH keys
ssh-keygen -t ed25519 -C "user@domain.com"
Copy public key to paste as needed:
xclip -sel clip < ~/.ssh/id_ed25519.pub
Folder structure
Update the folder structure. Basically changing the defaults locations of folders like ~/Downloads
and ~/Desktop
.
Create new folders.
cd ~
mkdir work dl docs media tpl pub \
media/{music,books,pics,vids,screens,torrents}
Make Ubuntu use our new folders. Edit ~/.config/user-dirs.dir
and update the file so it looks like this:
XDG_DESKTOP_DIR="$HOME/desk"
XDG_DOWNLOADS_DIR="$HOME/dl"
XDG_TEMPLATES_DIR="$HOME/tpl"
XDG_PUBLICSHARE_DIR="$HOME/pub"
XDG_DOCUMENTS_DIR="$HOME/docs"
XDG_MUSIC_DIR="$HOME/media/music"
XDG_PICTURES_DIR="$HOME/media/pics"
XDG_VIDEOS_DIR="$HOME/media/vids"
Fish configuration
Install Fisher.
Install z:
fisher install jethrokuan/z
Ubuntu configuration
Add Spanish:
- Settings
- Region & Language
- Input Sources
- Add Spanish
- Appearance
- Dark
- Dock
- Auto-hide the Dock: On
- Position on screen: Bottom
Install GNOME tweaks
sudo apt install gnome-tweaks
With GNOME Tweaks activate:
- Top Bar
- Activities Overview Hot Corner
- Battery Percentage
- Weekday
- Workspaces
- Static Workspaces
- Number of Workspaces: 5
- Workspaces span displays
- Static Workspaces
GNOME Terminal configuration
Download and install the Dracula theme for GNOME Terminal.
Restart your terminal to reflect the changes.
Tmux configuration
- Install tpm.
- Download and install the Dracula theme for Tmux.
Update ./config/tmux/tmux.conf
:
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'dracula/tmux'
set -g @dracula-plugins 'git, network-ping, attached-clients, network-vpn, weather, time'
set -g @dracula-show-left-icon 'uwu'
run -b '~/.tmux/plugins/tpm/tpm'
Install Node
Install n:
curl -L https://git.io/n-install | bash
Install Python
Install pyenv using pyenv-installer.
Be sure to install the build environment dependencies:
- https://github.com/pyenv/pyenv/wiki#suggested-build-environment
Git commit messages
Each commit message consists of a header, a body, and a footer.
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
Header
The header is mandatory and the scope is optional.
Type
Must be one of the following:
feat
: introduces a new feature to the codebasefix
: patches a bug in your codebaserefactor
: improves the code without changing functionalityBREAKING CHANGE
: major version
Additional types:
build
: a change that affects the build system or external dependencieschore
: same asbuild
butchore
is preferred, also any change that doesn’t fit in any other typeci
: changes to the CI configurationdocs
: changes to the documentationstyle
: white-space, formatting, semi-colons, etc.perf
: performance improvementstest
: adding or fixing
Scope
The scope can be empty. Scope can be any of these:
- category, part or section of the codebase we are affecting, e.g.:
api
,client
,tooling
- a specific package, library or dependency,e.g.:
moment.js
,requests
- a ticket number in case the current commit doesn’t close it, e.g.:
chore(123): update dependencies
Subject
Short (50 chars or less) summary of the change:
- use the imperative, present tense: “change” not “changed”
- don’t capitalize the first letter
- no dot (.) at the end
Footer
The footer should contain a closing reference to an issue if any and breaking changes.
Closes #123, #345
BREAKING CHANGE:
IE6 not supported anymore.
Semantic versioning
Conventional commits are designed to work with Semantic versioning.
feat
: minor versionfix
: patch versionBREAKING CHANGE
: major version
Examples
Add a new feature without breaking existing functionality. This bumps a minor version, e.g.: 1.2.0
to 1.3.0
.
feat: add search for transactions
Add new React component for searching transactions with autocompletion.
Include tests.
Closes #123, #234
Fix a bug. This bumps a patch version, e.g.: 1.3.0
to 1.3.1
.
bug(api): add correct status code for existing resources
We return `409` when trying to create a user with an existing email.
Closes #453
Add new feature that breaks existing functionality. This bumps a major version, e.g.: 1.3.1
to 2.0.0
.
feat!: add bank sync
This replace CSV import and use Plaid to connect to people's banks.
Closes #423, #424, #425
BREAKING CHANGE:
People won't be able to import transactions using CSV. Only Bank
Sync is available.
Resources
- Angular Commit Message Guidelines
- Do new features, updates, design use feat: in semantic commit message convention? (Stack Overflow)
- Karma commit message
- A Note About Git Commit Messages (Tim Pope)
- Semantic Commit Messages (Sparkbox)
- How can I write good Conventional Commit-style commit messages for one feature over multiple commits? (Stack Exchange)
- Conventional Commits
How to resize a disk on Ubuntu server 20.04
I had an issue with my Thinkpad x220; when I installed Ubuntu, I had only 100GB available out of 1000 GB. So it ran out of available space quickly.
To resize to all the space available, I ran these commands:
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
Sources:
- Ubuntu only use 100GB of 200 physical disk (Ubuntu Forums)
Deploy Gitea to Dokku
Requirements
- A server with Dokku installed and configured.
- The Dokku Postgres plugin.
- The Dokku letsencrypt plugin.
Steps
Create an application.
dokku apps:create gitea
Expose the ports for http
and ssh
. By default, gitea
exposes 3000
for http
and 22
for ssh
. We want our application to listen externally on port 80
, but we need to map our ssh
to a different port because 22
is used by the host.
We will rely on the docker-options plugin to expose ssh
properly.
# expose container `http` port 3000 on host `http` port 80
dokku proxy:ports-add gitea http:80:3000
# expose the container port 22 on host port 2222
dokku docker-options:add git deploy -p 2221:22
Add a rule in your firewall to allow connections on 2221
.
sudo ufw allow 2221/tcp
Create a storage directory for the Gitea files.
sudo mkdir /var/lib/dokku/data/storage/gitea_data
sudo chown user:user /var/lib/dokku/data/storage/gitea_data
dokku storage:mount gitea /var/lib/dokku/data/storage/gitea_data:/data
Pull and deploy the Docker image from dockerhub.
docker pull gitea/gitea:latest
docker tag gitea/gitea:latest dokku/gitea:latest
dokku git:from-image gitea dokku/gitea:latest
Add a Let’s encrypt TLS certificate with the Dokku letsencrypt plugin.
dokku letsencrypt:set git email <your-email>
dokku letsencrypt:enable git
Now, go visit gitea.<yourdomain>, e.g., gitea.yourdomain.com.
Configuration
Most of the options are autopopulated, use the following settings as needed.
- Get the database information from
dokku postgres:info gitea
. - Set the SSH port as
2221
. Gitea will use this to format your projects’ SSH connection info in the UI.
Resources
- Inspiration
- gitea-in-dokku
- Deploying Gogs to Dokku
- gogs-in-dokku
- Initializing an app repository from a docker image (Dokku docs)
No artificial intelligence was used in the making of this post.
Build your own ngrok
Expose your local development environment to the public Internet using a domain and a server (VPS).
Continue reading