Posts

Life is a marathon

life is a journey. It can be short or it can be long. It's not a short race if you choose to live. How far you go is totally depends on how long you want to go and how persistent you are. So put your sadness and weakness back, let's go and see how far we can reach.

How to set up a socket service as VPN with pure python?

 # Big direction 1. pure python socket proxy service, one py file 2. ufw allow port 3. use proxy_switch extension in broswer # Python script ``` """ Small Socks5 Proxy Server in Python from https://github.com/MisterDaneel/ Modified by yingshaoxo """ # Network import socket import select from struct import pack, unpack # System import traceback from threading import Thread, activeCount from signal import signal, SIGINT, SIGTERM from time import sleep import sys from multiprocessing import Process # # Configuration # MAX_THREADS = 200 BUFSIZE = 2048 TIMEOUT_SOCKET = 5 LOCAL_ADDR = '0.0.0.0' LOCAL_PORT = 2121 # Parameter to bind a socket to a device, using SO_BINDTODEVICE # Only root can set this option # If the name is an empty string or None, the interface is chosen when # a routing decision is made # OUTGOING_INTERFACE = "eth0" OUTGOING_INTERFACE = "" # # Constants # '''Version of the protocol''' # PROTOC

How to set up a webpage_based virtual desktop for your remote linux VPS?

``` docker stop webtop docker rm webtop docker run -d \   --name=webtop \   -e PUID=1000 \   -e PGID=1000 \   -e TZ=Europe/London \   -p 19999:3000 \   -v ~/.webtop:/config \   --shm-size="100mb" \   --restart unless-stopped \   ghcr.io/linuxserver/webtop ``` username abc password abc   http://your_ip:19999  

How to set up jupyter notebook in your server or VPS remotely with subdomain and cloudflare?

 How to set up jupyter notebook in server? # new jupyterlab does not allow cloudflare subdomain access no matter how you try, so we use old pip install jupyterlab==3.2.8 # set up password jupyter lab password # then modify a file 'vim ~/.jupyter/jupyter_server_config.json' to allow subdomain ``` {   "ServerApp": {     "password": "JkZ12Ij",     "allow_origin": "*",     "allow_remote_access": true   } } ~       ``` # new jupyterlab does not have 'jupyter lab' command, so you can only use 'jupyter server'. But it does not allow subdomain access. jupyter lab --ip 127.0.0.1 --port 9998 --allow-root /root/ # I use traefik to do proxy from subdomain to localhost, but use nginx will be easyer since nginx has many tutorial online # auto start, with "crontab -e" @reboot /usr/local/bin/jupyter lab --ip 127.0.0.1 --port 19998 --allow-root /root/

How to make your python code more stable? So it can get running both in python2.7 and python3.x

1. Use zero built-in library or third_party package Try to use built-in functions to do the same thing. If you only focus on one system, that would be easy.   """ abs() all() any() ascii() bin() bool() bytearray() bytes() callable() classmethod() dict() dir() enumerate() eval() exec() float() format() globals() hasattr() hash() help() hex() input() int() isinstance() issubclass() iter() len() list() locals() max() min() object() oct() open() ord() pow() print() property() range() repr() reversed() round() set() setattr() slice() sorted() staticmethod() str() sum() super() tuple() type() vars() zip() __import__() """ 2. Use no types The type will break python2.7, and it will make your code more complex if you use more than json 5 base types. Instead, use this template yingshaoxo created:   ``` Instead of using type in function, you can directly put the type after variable name, so that python2 could run it, for example: def hi(greeting_string):      result

How to make small software project?

How to reduce the burden on developers, reduce software size, optimize program performance, and increase compatibility? For different hardware, systems, and architectures, build different software packages or repositories and let different programmers manage them. For example, vim can be divided into vim_linux, vim_windows, vim_mac, vim_android, etc. If need more precise, it can be divided into vim_linux_amd64, vim_linux_arm64 In this way, you may find that only the developers of Unix are the smartest, and their project have the least amount of code, and their software are most stable. If the project has 0 dependencies, in theory, in that hardware machine it targets to, you can use that software forever without updating or internet access. For people who are looking for general cross platform project, they are stupid. They do not own those hardware or operation systems, so they can't make sure in the future, those stuff won't change. So cross platform software is the most unsta

Stop using third party packages that has many dependencies that the author didn't have a check before they use

33. "remove every backend project that uses node third party packages, they might has backdoor that could use your VPS as their VPS to act like a general web client for hackers"   it is even worse if you use npm in root VPS, because the npm will always use new version of a package or sub_package, how can you make sure your 3000 dependencies will not have a virus that could use your VPS root permission to do bad things?   it is the same for other package manager, for example, python pip. or golang package, java package, rust package, flutter package. in chinese, people usally call those machine that has those software running 'rou ji'. """ 利用 package manager 自动更新新版本的特性,做远控 轻而易举 就算不更新,利用现有的package,二进制文件或者脚本 一个post发到黑客服务器,它就知道你的电脑能不能被控制 对于root设备,被控制就是被完全控制,对于普通设备,就是被当成hacker web 客户端,可以被拿来在网上发垃圾信息、垃圾账号注册 到时候你的ip就会被当成坏ip被服务器墙掉 """

How to make a universal browser that adapts to web pages that either built decades ago or built from current time?

如何制作通用浏览器,使其自适应几十年甚至几百年间的网页? 让网站主在html meta tag下写一个数字,比如“build=1997” 那么在浏览器浏览该网页的时候,浏览器会自动切换到1997年的浏览器内核 #idea #yingshaoxo How to make a universal browser that adapts to web pages that either built decades ago or built from current time? Ask the website owner to write a number under the html meta tag, such as "build=1997". Then when the browser visit the web page, the browser will automatically switch to the 1997 browser kernel. By doing so, old webpage will work on new browser. #idea #yingshaoxo