Posts

Update software on Ubuntu 22.04 (arm64)

sudo apt update sudo apt upgrade

The relationship between pages/_app.js and pages/index.js in a Next.js

The relationship between pages/_app.js and pages/index.js in a Next.js application is foundational to how Next.js handles page rendering and application structure. Here's an overview of their roles and interplay: pages/_app.js - The Custom App Component : This is a special file in Next.js that allows you to override the default App component used by Next.js. It's the top-level component that gets executed for every page visit. It's useful for implementing application-wide page layouts or injecting additional data into pages. Whatever you include in _app.js (like global CSS, layout components, context providers) is accessible in every page of your application. It receives a Component prop, which is the active page being rendered (e.g., the content of pages/index.js or any other page), and pageProps , which are props specific to each page. pages/index.js - A Page Component : This file represents the homepage of your Next.js application. It's what gets rendered when

WSL2配置proxychains, 使得终端走宿主机代理

安装:           sudo apt-get update           sudo apt-get upgrade           sudo apt-get install proxychains4 获得宿主机 IP: cat /etc/resolv.conf | grep nameserver | awk '{ print $2 }' 查询代理软件端口:10810 编辑配置文件:sudo nano /etc/proxychains4.conf           change:socks4 127.0.0.1 9095         to:socks5 xxx.xxx.xxx.xxx 10810         中间的x是上面查出来的ip地址,10810是v2rayN局域网(不是本地)监听的端口。          并在 [ProxyList]之前添加:           # Exclude localhost           localnet 127.0.0.0/255.0.0.0 测试:           proxychains4 curl -L myip.ipip.net           proxychains4 curl -L cip.cc vscode走代理:proxychains4 code . 更新proxychains:           sudo apt-get update # This will update the list of available packages           sudo apt-get upgrade # This will upgrade the installed packages to the latest versions 注意:proxychains 与 proxifier 会冲突,只需用二者之一。 参考文献:           WSL2配置proxychains           WSL2 中访问宿主机 Windows 的代理           WSL2配置网络代理

In the process of data transfer, what are differences between server side sessions and authentication tokens?

Server-side sessions and authentication tokens are both methods used to authenticate users and maintain their state over the internet. However, they differ in how they store and manage this information. Server-Side Sessions In server-side sessions, the user state is stored on the server's memory. When a user logs in, the server creates and stores the session data (such as user account data and role) in its memory. The server then sends a session ID to the user's browser, which is typically stored in a cookie. This session ID is sent back to the server with each subsequent request, allowing the server to recognize and authenticate the user. This method requires the server to keep track of active sessions, which can consume significant memory resources if there are many concurrent users . Authentication Tokens Authentication tokens, on the other hand, encapsulate the user state within the token itself. When a user logs in, the server generates a token that contains user informati

About Seedr

Seedr is a cloud-based torrent client that allows users to download torrents and store them in a virtual drive, eliminating the need for a local storage device. With Seedr, users can access their torrents anytime and anywhere, as long as they have an internet connection. One of the key benefits of Seedr is its ease of use. To start downloading torrents, all you need to do is sign up for an account and paste the torrent link into the platform. Seedr will take care of the rest, downloading the torrent in the background and saving it to your virtual drive. This makes it a great option for people who don't have the space or technical know-how to set up their own torrent client. Another advantage of Seedr is its speed. The platform uses a high-speed server network to download torrents, meaning you can get your files faster than with traditional torrent clients. Seedr also offers a premium service that provides users with even faster download speeds and additional storage space. One of t

MongoDB & Mongoose - A Refresher

 1. What is MongoDB? MongoDB is a no SQL database, which stores Documents in Collections instead of Records in Tables as in SQL It is used to store application data Stored data doesn't enforce a specific data schema or any relations MongoDB can also be easily connected to Node and Express, but we do not connect it directly to our front end (React) MongoDB is a powerful database and it can be easily integrated into a node express environment 2. SQL vs NoSQL NoSQL(e.g MongoDB) do not enforce a strict data schema(collections can contain documents with different schemas),  have less focus on relations, works with independent documents SQL(e.g MySQL) enforce a strict data schema(define the tables and the corresponding records, normally don't deviate from that structure ), relations are a core feature the records are related 3. Connecting React to a Database? Connecting react to the database is a bad idea It is a highly insecure approach, secure authentication is not really possible

Node.js & Express.js - A Refresher

 1. What is Node.js? Like Browser is one host environment of that Javascript of frontend, Node.js is a host environment for Javascript of backend Chrome's Javascript engines V8  has all been cloned and is now maintained as a standalone project working without a browser and enriched with some extra APIs that is basically Node.js, it allows us to run Javascript outside of the browser Compare to V8, Node.js dropped some APIs(e.g. DOM API), and added some APIs(e.g. Filesystem) 2. A Simple Node.js Code Node.js code are just normal javascript code with extra node  api In Node.js runtime environment, there are a few globally function (e.g., require) Between different Node.js module (javascript file), we can transfer object through require and export A simple Node.js Code: const fs = require("fs"); const userName = "Light"; fs.writeFile("./user-data.txt", "Name: " + userName, (error) => { if (error) { console.log(error); return; }