> Web

MySQL Char & Index

1. Types of char Type Size Range Extra Space Query Speed CHAR Fixed 1~255 0 fast VARCHAR Dynamic 1~65535 1~2 bytes slow TEXT Dynamic 1~65535 2 bytes slowest 2. Index Create index for database can speed up query. 2.1 How to create index create index idx_name on employee(name); -- or alter table employee add index idx_name(name); -- unique index create unique index idx_name on employee(name); 2.2 How to check index show index from employee; 2.

Continue reading

Router & CORS

1. Basic Setting We are developing a web applications. Gin is for backend and vue is for frontend. However, I often encouter router problems when sending request from frontend to the backend. Here are quick rules to avoid these problems. 2. Router //routers.go func Router() *gin.Engine { r := gin.Default() r.Use(middleware.Cors()) user := r.Group("/user") { user.GET("/test/", controllers.Test) user.GET("/", controllers.GetUsers) user.GET("/:id", controllers.GetUser) user.POST("/new", controllers.NewUser) user.POST("/update/:id", controllers.UpdateUser) } return r } <script> // add end slash const res = await $fetch("http://localhost:8080/user/test/") const res = await $fetch("http://localhost:8080/user/"); // no end slash const res = await $fetch("http://localhost:8080/user/1"); const res = await $fetch("http://localhost:8080/user/new", { .

Continue reading

Internet Basics

1. Open System Interconncetion Reference Model (OSI model) Physical Layer: Network interface controller (网卡), ethernet hub (集线器), network switch, transmission medium. It converts digital bits to electrical, radio or optical signals. Voltage characteristics are defined. Datalink Layer: Medium access control (MAC) layer, logical link control (LLC) layer. Correct errors that may occur in physical layers. Network Layer: Provides to transfer packets from node to node. (IP) Transport Layer: Provides to transfer variable length data sequences from source host to destination host.

Continue reading

Intro to Redis

1. Basic Concepts Redis is a NoSql database. Its characteristics are non-structured, non-relational, no SQL grammar. Other NoSQL includes MongoDB, elaticsearch. Besides, Redis only has base transaction. Redis stores key-value, runs in single thread with low latency. Data persistence is supported in case of blackout. 2. Install See Redis. For mac os, we can just run brew install redis 3. Basic Commands brew services start redis # start redis redis-cli -h 127.

Continue reading

All kinds of Django View

1. First Example Suppose that we are going to build a blog application. The following codes will create the index page. # urls.py urlpatterns = [ path('', views.index, name='index'), ] # views.py def index(request): latest = Post.objects.order_by("-modified_time") return render(request, "index.html", {"post_list": latest}) If we use View class, the codes will be easier to read. # urls.py urlpatterns = [ path('', views.IndexView.as_view(), name='index'), ] # views.py from django.views.generic import ListView class IndexView(ListView): queryset = Post.

Continue reading

Author's picture

LI WEI

苟日新,日日新,又日新

Not yet

Tokyo