2025-10-30 23:00:00
n8n is a powerful workflow automation tool that allows you to connect different services and automate tasks. While n8n offers a cloud version, self-hosting provides more control and flexibility. The recommended way to self-host n8n is by using Docker. In this guide, we will walk through how to deploy n8n using Docker Compose, which simplifies the management of multi-container Docker applications.
docker-compose.yml for n8nFor those who want to get straight to it, here is a docker-compose.yml file for a basic n8n setup with a PostgreSQL database.
version: '3.8'
services:
  n8n:
    image: docker.n8n.io/n8nio/n8n
    restart: always
    ports:
      - "5678:5678"
    environment:
      - DB_TYPE=postgresdb
      - DB_POSTGRESDB_HOST=postgres
      - DB_POSTGRESDB_PORT=5432
      - DB_POSTGRESDB_DATABASE=${POSTGRES_DB}
      - DB_POSTGRESDB_USER=${POSTGRES_USER}
      - DB_POSTGRESDB_PASSWORD=${POSTGRES_PASSWORD}
      - N8N_BASIC_AUTH_ACTIVE=true
      - N8N_BASIC_AUTH_USER=${N8N_BASIC_AUTH_USER}
      - N8N_BASIC_AUTH_PASSWORD=${N8N_BASIC_AUTH_PASSWORD}
      - GENERIC_TIMEZONE=${GENERIC_TIMEZONE}
    volumes:
      - n8n_data:/home/node/.n8n
    depends_on:
      - postgres
  postgres:
    image: postgres:13
    restart: always
    environment:
      - POSTGRES_DB=${POSTGRES_DB}
      - POSTGRES_USER=${POSTGRES_USER}
      - POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
    volumes:
      - postgres_data:/var/lib/postgresql/data
volumes:
  n8n_data:
  postgres_data:
You will also need a .env file in the same directory to store your credentials:
# PostgreSQL
POSTGRES_DB=n8n
POSTGRES_USER=n8nuser
POSTGRES_PASSWORD=yoursecurepassword
# n8n Basic Auth
N8N_BASIC_AUTH_USER=admin
N8N_BASIC_AUTH_PASSWORD=yoursecureadminpassword
# Timezone
GENERIC_TIMEZONE=Asia/Shanghai
Before you start, make sure you have Docker and Docker Compose installed on your system.
Create a directory for your n8n setup and navigate into it.
mkdir n8n-deployment
cd n8n-deployment
Create the docker-compose.yml file and paste the content from the "Quick Glance" section above.
Create the .env file and add your desired credentials.
Start the services using Docker Compose.
bash
docker compose up -d
This command will pull the necessary Docker images and start the n8n and PostgreSQL containers in the background.
Once the containers are running, you can access your n8n instance by navigating to http://localhost:5678 in your web browser. You will be prompted to set up an owner account for your n8n instance.
To update your n8n instance to the latest version, follow these steps:
Pull the latest n8n image:
docker compose pull n8n
Restart the services:
bash
docker compose up -d
Docker Compose will recreate the n8n container with the new image while keeping your data stored in the Docker volumes.
By using Docker Compose, you can easily deploy, manage, and update your self-hosted n8n instance. This setup provides a robust and scalable environment for your workflow automations.
2025-10-30 18:00:00
For anyone writing academic papers, articles, or books in LaTeX, meeting word count requirements is a common task. Unlike traditional word processors, counting words in a LaTeX document can be tricky due to the presence of commands and environments. TeXcount is a powerful command-line utility specifically designed for this purpose. It intelligently parses your LaTeX document to provide an accurate word count, along with other useful statistics.
For a quick summary of word counts in your LaTeX file, run the following command in your terminal:
texcount -inc your_document.tex
TeXcount is a Perl script and is included by default in most major TeX distributions, such as TeX Live, MiKTeX, and MacTeX. You likely already have it installed. You can verify this by opening your terminal and typing:
texcount -v
If it's installed, you will see version information. If not, you should install it through your TeX distribution's package manager.
The simplest way to use TeXcount is to run it on your main .tex file:
texcount your_document.tex
This will produce a detailed breakdown of words in the text, headers, and captions, as well as counts of headers, floats, and math environments.
TeXcount offers a variety of options to customize its output.
If your document is split into multiple files using \input{} or \include{}, you need to tell TeXcount to include them in the count. The -inc flag does exactly that:
texcount -inc your_document.tex
This is one of the most common and useful options.
Often, you just want the final word count. The -total option will provide a sum of all word counts:
texcount -inc -total your_document.tex
This will give you a clean, single number for the total words.
To count characters instead of words, use the -char option. If your document uses UTF-8 encoding (which is standard for most modern documents), it's good practice to specify it with -utf8:
texcount -char -utf8 your_document.tex
TeXcount can also be instructed to ignore specific parts of your document. For example, you can add special comments in your LaTeX file to control TeXcount:
%TC:ignore - Start ignoring text from this point.%TC:endignore - Resume counting.%TC:insert N - Add N words to the count.For example, to exclude a paragraph from the word count:
\section{Introduction}
This paragraph will be counted.
%TC:ignore
\begin{comment}
This entire block, including the text inside, will be ignored by TeXcount.
It's useful for notes or sections you want to exclude from the final count.
\end{comment}
%TC:endignore
This paragraph will be counted again.
By mastering these simple commands and options, you can get a reliable word count for your LaTeX documents, making it easier to adhere to submission guidelines.
2025-10-29 20:00:00
For academics, researchers, and students, LaTeX is the gold standard for producing beautifully typeset documents, from scientific papers to dissertations. However, the traditional workflow involving clunky, outdated editors can feel cumbersome.
This guide will show you how to create a modern, streamlined, and highly efficient LaTeX environment on your Mac using the power of MacTeX and the versatility of Visual Studio Code with the LaTeX Workshop extension.
bash
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
MacTeX is a complete TeX distribution for macOS. It includes everything you need to start compiling LaTeX documents. The simplest way to install it is via Homebrew.
Open your terminal and run:
brew install --cask mactex
Note: MacTeX is a large installation (over 5GB), so this may take some time. It includes the TeX Live backend, GUI applications like TeXShop, and the tlmgr package manager.
Now, let's equip VS Code with the necessary tools.
Cmd+Shift+X).LaTeX Workshop.LaTeX Workshop is incredibly powerful and will automatically detect your MacTeX installation.
Create a new folder for your project.
Open this folder in VS Code (File > Open Folder...).
Create a new file named document.tex.
Paste the following minimal LaTeX code into the file:
\documentclass{article}
\title{My First LaTeX Document with VS Code}
\author{Your Name}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
Hello, world! This is my first document created using MacTeX and the LaTeX Workshop extension in Visual Studio Code.
It's easy to write math formulas like \( E = mc^2 \).
\subsection{Features}
Here are some things I like:
\begin{itemize}
    \item Live preview
    \item Syntax highlighting
    \item Easy compilation
 பகிர்
\end{itemize}
\end{document}
This is where the magic happens.
document.tex file open, click the Build LaTeX project button (a green play icon) in the top-right corner of the editor, or open the Command Palette (Cmd+Shift+P) and type LaTeX Workshop: Build LaTeX project.LaTeX Workshop: View LaTeX PDF.The PDF will open in a new tab right inside VS Code!
Pro Tip: Auto-build on Save
By default, LaTeX Workshop is configured to automatically recompile your document every time you save the .tex file. This gives you a near-instant live preview of your changes.
pdflatex compiler, make sure MacTeX is installed correctly. You can specify the path in VS Code's settings.json if needed, but this is rarely necessary with a standard Homebrew installation.fancyhdr.sty): MacTeX comes with thousands of packages, but if you need a rare or new one, you can install it using the TeX Live Manager (tlmgr). Open your terminal and run:
bash
sudo tlmgr install <packagename>
You now have a professional-grade LaTeX environment on your Mac. This setup combines the typesetting power of TeX with the modern conveniences of VS Code, creating a workflow that is both efficient and enjoyable. Happy typesetting!
2025-08-22 05:59:02
Creating a new Git repository is a common task for developers. While you can always do this from the web interface of GitHub or GitLab, using command-line tools can significantly speed up your workflow, especially when you're already working in the terminal. In this post, we'll explore how to use gh for GitHub and glab for GitLab to create a remote repository and push your local project to it.
gh to Create a GitHub RepositoryThe gh command is the official GitHub CLI tool. If you don't have it installed, you can follow the installation instructions on the official website.
Once installed and authenticated, you can create a new repository with the following command:
gh repo create
This command will start an interactive prompt, asking for the repository name, visibility (public, private, or internal), and whether you want to clone it or push an existing local repository.
To create a repository and push your current local folder, you can run:
gh repo create <repo-name> --public --source=. --remote=origin
git push -u origin main
Replace <repo-name> with your desired repository name. The --source=. flag tells gh to use the current directory as the source, and --remote=origin sets the remote name.
glab to Create a GitLab RepositoryFor GitLab users, glab is the official CLI tool. You can find installation instructions on its official documentation.
After installation and authentication, creating a new repository is just as simple.
To create a new repository interactively, run:
glab repo create
This will guide you through the process of naming your repository and setting its visibility.
To create a repository and push your current local project, you can use:
# Official gitlab
glab repo create <your-namespace>/<repo-name> --public
# Private host gitlab
glab repo create <your-private-host>/<your-namespace>/<repo-name> --private
# Add remote and push
git remote add origin "https://<host>/<your-username>/<repo-name>.git"
git push -u origin main
Replace <repo-name> and <your-username> accordingly. glab will create the remote repository, and then you can add it as a remote and push your code.
Using command-line tools like gh and glab can make your development workflow more efficient. With just a few commands, you can initialize a local repository, create a remote one, and push your code without ever leaving the terminal.
2025-08-19 19:06:29
Good diagrams compress complex ideas into shapes, arrows, and frames the way code compresses logic. When diagrams are generated from code, they can be versioned, reviewed, and kept in sync with the system. This post compares six popular options and shows minimal working examples so you can pick the right tool for your team and workflow.
Think about three things: where the diagram will live, how often it will change, and who must edit it. If you want diagrams embedded in docs and PRs, a text-first format like Mermaid or PlantUML works well. If you prefer diagrams sourced from real code, Diagrams (Python) or Go Diagrams integrate with your language toolchain. For quick sketches, ASCII is frictionless. For brainstorming and note-taking, Markmap turns Markdown into interactive mind maps.
Diagrams is a Python library that renders architecture diagrams from code. It excels at cloud/system architecture where you want provider icons, clusters, and consistent styling. Because it is Python, you can compose generators, reuse components, and test the code that produces your diagram.
# pip install diagrams
from diagrams import Diagram, Cluster
from diagrams.aws.compute import EC2
from diagrams.aws.database import RDS
from diagrams.aws.network import ELB
with Diagram("web-service", show=False):
    with Cluster("App Tier"):
        app = [EC2("app1"), EC2("app2")]
    db = RDS("primary-db")
    lb = ELB("edge")
    lb >> app >> db
Use it when you need repeatable, code-reviewed architecture diagrams with cloud icons and when Python is already in your stack.
Go Diagrams follows a similar idea for the Go ecosystem. It lets you define nodes and edges in Go, then renders to SVG/PNG. Its strengths are type safety, simple composition, and a natural fit for Go services where developers prefer staying in one language.
package main
func main() {
    // Pseudocode-style example to convey intent
    g := NewDiagram("payments")
    api := g.Node("API")
    svc := g.Node("Service")
    db  := g.Node("DB")
    api.Connect(svc)
    svc.Connect(db)
    g.Render("payments.svg")
}
Pick it if your team writes Go and wants diagrams generated within the same toolchain, for CI-friendly outputs and code reviews.
Mermaid renders diagrams from a concise Markdown-like syntax, supported by many platforms (including GitHub, GitLab, and numerous docs tools). It is ideal for documentation-driven teams because diagrams live beside prose and update via simple edits.
flowchart TD
A[Client] --> B[API Gateway]
B --> C{Auth?}
C -- yes --> D[Service]
C -- no  --> E[401]
D --> F[(DB)]
Use Mermaid for architectural sketches, flows, and sequence diagrams directly in Markdown files, wikis, and PR descriptions.
PlantUML is a mature, text-based system supporting many diagram types: sequence, component, class, state, and more. It provides powerful styling, includes, and skinparams for large documentation codebases.
@startuml
actor User
participant "Web App" as Web
database DB
User -> Web: POST /login
Web -> DB: query credentials
DB --> Web: result
Web --> User: 200 OK
@enduml
Choose PlantUML when you need breadth of diagram types, fine-grained styling, and modular includes across a large doc set.
ASCII diagrams are plain text drawings you can create in any editor and keep in code blocks. They render everywhere, diff cleanly, and require no toolchain. They are perfect for quick design notes, README snippets, and terminal-first workflows.
+---------+      +----------+      +--------+
| Client  | ---> |  Proxy   | ---> |  API  |
+---------+      +----------+      +--------+
                      |                 |
                      v                 v
                   Cache            Database
Reach for ASCII when you value speed, universality, and zero dependencies over polish.
Markmap converts Markdown lists into interactive mind maps. It is excellent for brainstorming, note-taking, and structuring research. Because the source is Markdown, it works well with existing docs and knowledge bases.
# Project Kickoff
- Scope
  - MVP
  - Out of scope
- Architecture
  - Services
  - Data flow
- Risks
  - Scaling
  - Compliance
Use Markmap to ideate and present hierarchies during early phases, then evolve those notes into formal docs.
If you want code-native, icon-rich architecture diagrams that stay in sync with cloud resources, prefer Diagrams (Python) or Go Diagrams depending on your language. If you need frictionless diagrams in docs and PRs with broad platform support, pick Mermaid. If you require advanced diagram types, skinning, and modularization, choose PlantUML. For fast, dependency-free sketches, use ASCII. For early-stage thinking and presentations built from notes, adopt Markmap.
Keep diagram sources in the same repo as the system they describe so changes travel with code. Add a CI step to render and validate diagrams to prevent drift. Create reusable templates for common topologies and enforce naming and styling conventions. For mixed environments, standardize on a text-first format like Mermaid or PlantUML for documentation and complement it with language-native generators (Diagrams or Go Diagrams) for architecture that benefits from code reuse.
Treat diagrams as living artifacts rather than static images. When they are generated from code or text, they become reviewable, testable, and easy to evolve. Pick one primary format for your team and add others only when they clearly reduce friction or improve clarity.
2025-08-09 23:07:37
Need quick access to your terminal? iTerm2 offers a seamless way to summon it with a system‑wide hotkey—just like a drop‑down terminal. Here's how to set it up.
This creates a dedicated, always-accessible, overlay-style terminal window—ideal for quick access.
Now, pressing your chosen hotkey will toggle this profile in a dedicated window—without creating a new one.
| Method | Steps | Pros | 
|---|---|---|
| Dedicated Hotkey Window | Preferences → Keys → Create Dedicated Hotkey Window → Configure options | Fast setup, always-available overlay | 
| Existing Profile | Preferences → Profiles → (Profile) → Keys → Enable hotkey window → Configure hotkey | Reuses your customized profile and settings | 
Both approaches work well—choose whichever fits your workflow:
With your hotkey set, your terminal is gone—until you need it again.