Skip to content

Instantly share code, notes, and snippets.

View tanphongtr's full-sized avatar

Phong Tran tanphongtr

View GitHub Profile

Original article: https://seeinglogic.com/posts/visual-readability-patterns/

This article discusses various visual patterns that contribute to code complexity and make it difficult to read. It examines metrics like Halstead Complexity and Cognitive Complexity, highlighting their strengths and weaknesses in measuring readability. The author concludes that while no single metric is perfect, they provide a framework for understanding and discussing code quality. The main takeaway is that writing readable code involves using simple, familiar patterns, creating smaller functions, and managing variables effectively.

Here are the main rules for making code easy to read, with examples:

1. Line/Operator/Operand Count Make smaller functions with fewer variables and operators.

  • Hard to Read (More operators and operands):
@tanphongtr
tanphongtr / README.md
Created May 28, 2024 07:31 — forked from Informatic/README.md
openlgtv webOS hacking notes

This is just a dump of some interesting undocumented features of webOS (3.8 specifically, on early 2018 4k LG TV) and other development-related tips.

Homebrew app ideas

@tanphongtr
tanphongtr / gist:c1ecad4628e883aed6607515bad4dbe8
Last active December 4, 2023 13:40
Fix failed to install: pip install mysqlclient (MySQL 8.0.33) #584
$ export MYSQLCLIENT_LDFLAGS=$(pkg-config --libs mysqlclient)
$ export MYSQLCLIENT_CFLAGS=$(pkg-config --cflags mysqlclient)
$ pip install mysqlclient

PyMySQL/mysqlclient#584

@tanphongtr
tanphongtr / docker-api-port.md
Created August 28, 2023 04:32 — forked from styblope/docker-api-port.md
Enable TCP port 2375 for external connection to Docker

Enable TCP port 2375 for external connection to Docker

See this issue.
Docker best practise to Control and configure Docker with systemd.

  1. Create daemon.json file in /etc/docker:

     {"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]}
    
@tanphongtr
tanphongtr / nginx_macos.md
Created July 23, 2023 18:50 — forked from osamaqarem/nginx_macos.md
Nginx on MacOS

Install nginx (Homebrew)

brew install nginx

Configuration file for nginx will be at /usr/local/etc/nginx/nginx.conf

Web apps can be stored at /usr/local/var/www

Commands

Start:

@tanphongtr
tanphongtr / rest-api-response-format.md
Created September 12, 2022 09:05 — forked from igorjs/rest-api-response-format.md
REST API response format based on some of the best practices
# Text
print("Hello World!")