### Install and Run json-server
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub90.md
Commands to install the json-server package globally and start a mock API server using a local JSON file.
```bash
# 安装
npm install -g json-server
# 启动
json-server --watch db.json
```
--------------------------------
### Install and Run Label Studio
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub77.md
Commands to install the data annotation tool via pip and start the local server.
```shell
# 安装
pip install -U label-studio
# 运行
label-studio
```
--------------------------------
### Quick start with svrx
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub44.md
Commands to install and run the svrx development workbench.
```bash
npm install -g @svrx/cli
mkdir example && cd example
echo '
Hello svrx!' > index.html
svrx
```
--------------------------------
### Start HTTP server with Cicada
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub30.md
A minimal example demonstrating how to launch a web server using the Cicada framework.
```java
public class MainStart {
public static void main(String[] args) throws InterruptedException {
CicadaServer.start(MainStart.class,"/cicada-example") ;
}
}
```
--------------------------------
### Install and run tiptop
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub72.md
Commands to install and launch the tiptop system monitoring tool.
```bash
安装:pip install tiptop
运行:tiptop
```
--------------------------------
### Implement HTTP Routing with httprouter
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub87.md
A basic example demonstrating how to define routes and start an HTTP server using the httprouter package.
```go
package main
import (
"fmt"
"net/http"
"log"
"github.com/julienschmidt/httprouter"
)
func Index(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
fmt.Fprint(w, "Welcome!\n")
}
func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
fmt.Fprintf(w, "hello, %s!\n", ps.ByName("name"))
}
func main() {
router := httprouter.New()
router.GET("/", Index)
router.GET("/hello/:name", Hello)
log.Fatal(http.ListenAndServe(":8080", router))
}
```
--------------------------------
### Install and Use LuaRocks
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub58.md
Commands for downloading, compiling, and installing the LuaRocks package manager, followed by a basic usage example.
```bash
$ wget https://luarocks.org/releases/luarocks-3.5.0.tar.gz
$ tar zxpf luarocks-3.5.0.tar.gz
$ cd luarocks-3.5.0
$ ./configure && make && sudo make install
$ sudo luarocks install luasocket
$ lua
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
> require "socket"
```
--------------------------------
### Install and Run Rustlings
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub54.md
Commands to clone, install, and start the rustlings learning environment.
```bash
安装:
git clone https://github.com/rust-lang/rustlings
cd rustlings
git checkout tags/4.0.0 # or whatever the latest version is (find out at https://github.com/rust-lang/rustlings/releases/latest)
cargo install --force --path .
安装完后,运行:
rustlings watch
```
--------------------------------
### Initialize a Blade Web Application
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub21.md
A basic example showing how to start a web server using the Blade Java framework.
```java
public static void main(String[] args) {
Blade.me().get("/", (req, res) -> {
res.text("Hello Blade");
}).start();
}
```
--------------------------------
### Install and Initialize Publish
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub57.md
Commands to clone the Publish repository, build it, and initialize a new website project.
```bash
$ git clone https://github.com/JohnSundell/Publish.git
$ cd Publish
$ make
$ mkdir MyWebsite
$ cd MyWebsite
$ publish new
```
--------------------------------
### Install and Run Gotty
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub52.md
Provides the command-line instructions for installing and executing the Gotty terminal-to-web tool.
```bash
安装:go get github.com/yudai/gotty
运行:gotty [options] []
```
--------------------------------
### Install and Run go-pry
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub70.md
Commands to install the Go interactive REPL tool and launch it with specific packages.
```bash
# 安装
go get github.com/d4l3k/go-pry
go install -i github.com/d4l3k/go-pry
# 运行
go-pry -i="fmt,math,strconv"
```
--------------------------------
### Initialize and Run a Jekyll Blog
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub36.md
Commands to install, create, and serve a static site using Jekyll.
```bash
1. 安装 jekll:gem install bundler jekyll
2. 创建项目:jekyll new my-awesome-site
3. 进入新创建的项目:cd my-awesome-site
4. 本地运行:bundle exec jekyll serve
5. 本地访问地址:http://localhost:4000
```
--------------------------------
### Initialize Tailwind Landing Page Template
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub97.md
Commands to clone the repository, install dependencies, and start the development server for the landing page template.
```bash
git clone 项目
yarn install
yarn dev
# http://localhost:3000
```
--------------------------------
### Perform HTTP GET Request with nic
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub38.md
Example of using the nic package to perform a simple HTTP GET request and handle the response.
```go
resp, err := nic.Get("http://example.com", nil)
if err != nil {
log.Fatal(err.Error())
}
fmt.Println(resp.Text)
```
--------------------------------
### Run PythonPlantsVsZombies
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub45.md
Setup instructions for running the game project locally.
```text
1. 需要 Python 3
2. 安装依赖库:pip install pygame
3. python main.py
```
--------------------------------
### Initialize a go-zero Web Server
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub56.md
Demonstrates the basic setup for a go-zero service, including configuration loading and handler registration.
```go
func main() {
flag.Parse()
var c config.Config
conf.MustLoad(*configFile, &c)
ctx := svc.NewServiceContext(c)
server := rest.MustNewServer(c.RestConf)
defer server.Stop()
handler.RegisterHandlers(server, ctx)
server.Start()
}
```
--------------------------------
### Install dependencies
Source: https://github.com/521xueweihan/hellogithub/blob/master/script/github_bot/README.md
Install the required Python packages for the bot.
```bash
pip install -r requirements.txt
```
--------------------------------
### Install and run nes emulator
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub30.md
Commands to install the Go-based NES emulator and execute a ROM file.
```bash
1. 安装
go get github.com/fogleman/nes
2. 运行
nes [rom文件的路径]
```
--------------------------------
### Initialize Minum Web Framework
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub91.md
Shows how to initialize the Minum system and register a basic GET endpoint to return HTML content.
```java
package org.example.myproject;
import com.renomad.minum.web.*;
public class Main {
public static void main(String[] args) {
// Start the system
FullSystem fs = FullSystem.initialize();
// Register some endpoints
fs.getWebFramework().registerPath(
RequestLine.Method.GET,
"",
request -> Response.htmlOk("Hi there world!
"));
fs.block();
}
}
```
--------------------------------
### Manage processes with supervisord
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub80.md
Demonstrates defining a program in a configuration file and starting the supervisord service.
```bash
$ cat supervisor.conf
[program:test]
command = /your/program args
$ supervisord -c supervisor.conf
```
--------------------------------
### Install Pi-Apps on Raspberry Pi
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub82.md
Commands to clone the repository and execute the installation script for the Pi-Apps store.
```shell
# 下载
git clone https://github.com/Botspot/pi-apps
# 安装
~/pi-apps/install
```
--------------------------------
### Configure CoolViewPager
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub29.md
Example setup for the CoolViewPager component, demonstrating vertical scrolling and infinite loop configuration.
```java
public class ActivityEdgeEffectColor extends BaseActivity {
private CoolViewPager vp;
private void initViewPager(){
vp = findViewById(R.id.vp);
vp.setScrollMode(CoolViewPager.ScrollMode.VERTICAL);
vp.setAutoScroll(true,1000);
vp.setAutoScrollDirection(CoolViewPager.AutoScrollDirection.BACKWARD);
vp.setInfiniteLoop(true);
vp.setScrollDuration(true,600);
vp.setDrawEdgeEffect(true);
vp.setEdgeEffectColor(getResources().getColor(R.color.colorPrimary));
}
}
```
--------------------------------
### Log JSON with Zerolog
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub43.md
Example of initializing and using the zerolog library to output structured JSON logs.
```go
package main
import (
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func main() {
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
log.Info().Msg("hello world")
}
// Output: {"time":1516134303,"level":"info","message":"hello world"}
```
--------------------------------
### Compile and Run ip2region C Example
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub14.md
Commands to navigate to the C binding directory, compile the searcher, and execute it against the database file.
```bash
cd binding/c/
gcc -g -O2 testSearcher.c ip2region.c
./a.out ../../data/ip2region.db
```
--------------------------------
### Deploy weiboSpider for Data Collection
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub65.md
Clone the repository, install dependencies, and execute the module to start the web crawler.
```bash
# 安装
$ git clone https://github.com/dataabc/weiboSpider.git
$ cd weiboSpider
$ pip install -r requirements.txt
# 启动
$ python3 -m weibo_spider
```
--------------------------------
### Install Software with Scoop
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub100.md
Use the scoop command-line tool to install applications and manage dependencies on Windows.
```bash
scoop install sudo
sudo scoop install 7zip git openssh --global
scoop install aria2 curl grep sed less touch
scoop install python ruby go perl
```
--------------------------------
### Initialize FXGL Game Application
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub47.md
Demonstrates the basic setup for a game application using the FXGL framework.
```java
public class BasicGameApp extends GameApplication {
@Override
protected void initSettings(GameSettings settings) {
settings.setWidth(800);
settings.setHeight(600);
settings.setTitle("Basic Game App");
}
public static void main(String[] args) {
launch(args);
}
}
```
--------------------------------
### Preview Markdown with Grip
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub105.md
Use these commands to navigate to your repository and start a local server to preview GFM files.
```bash
$ cd myrepo
$ grip
* Running on http://localhost:6419/
```
--------------------------------
### Install SwiftFormat
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub75.md
Commands to install the Swift code formatter on macOS and Linux environments.
```shell
# macOS
$ brew install swiftformat
# Linux
$ mint install nicklockwood/SwiftFormat
```
--------------------------------
### Valval Web Server Implementation
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub46.md
Basic setup for a web server using the V language framework Valval.
```v
// demo.v
import valval
fn hello(req valval.Request) valval.Response {
return valval.response_ok('hello world')
}
fn main() {
mut app := valval.new_app(true)
app.register('/', hello)
valval.runserver(app, 8012)
}
```
--------------------------------
### Install and Sync Files with rclone
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub29.md
Commands to install rclone and synchronize local directories to cloud storage buckets.
```bash
# 安装
$ curl https://rclone.org/install.sh | sudo bash
# 例如同步本地文件夹到 AWS S3 存储桶
$ rclone sync /home/local/directory remote:bucket
```
--------------------------------
### Initialize and Run a Colly Web Crawler
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub77.md
Demonstrates basic setup for the Colly Go framework, including collector initialization, HTML link traversal, and request logging.
```go
func main() {
c := colly.NewCollector()
// Find and visit all links
c.OnHTML("a[href]", func(e *colly.HTMLElement) {
e.Request.Visit(e.Attr("href"))
})
c.OnRequest(func(r *colly.Request) {
fmt.Println("Visiting", r.URL)
})
c.Visit("https://go-colly.org/")
}
```
--------------------------------
### Install and Configure django-silk
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub78.md
Install the performance profiling tool and register its middleware and app in Django settings.
```shell
# 安装
pip install django-silk
# 中间件的方式使用
MIDDLEWARE = [
...
'silk.middleware.SilkyMiddleware',
...
]
INSTALLED_APPS = (
...
'silk'
)
```
--------------------------------
### Install and Update Halo
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub35.md
Use these shell commands to install or update the Halo blog system.
```bash
# 安装 Halo
$ yum install -y wget && wget -O halo-cli.sh https://git.io/fxHqp && bash halo-cli.sh -i
# 更新 Halo
$ bash halo-cli.sh -u
```
--------------------------------
### Deploy Static Blogs with uptoc
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub50.md
Commands to install and use the uptoc tool for deploying static blogs to cloud storage providers.
```bash
# 安装
curl -sSf http://uptoc.saltbo.cn/install.sh | sh
# 使用
uptoc --driver oss --region cn-beijing --access_key xxx --access_secret xxx --bucket demo-bucket /opt/blog/public
```
--------------------------------
### Install and Run mongoaudit
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/en/HelloGitHub11.md
Commands for installing and executing the MongoDB penetration testing tool.
```bash
pip install mongoaudit
```
```bash
python mongoaudit
```
--------------------------------
### Install docui via Homebrew or Go
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub35.md
Use these commands to install the docui terminal Docker management tool on your system.
```bash
# Homebrew
$ brew tap skanehira/docui
$ brew install docui
# go get
$ go get -d github.com/skanehira/docui
$ cd $GOPATH/src/github.com/skanehira/docui
$ GO111MODULE=on go install
```
--------------------------------
### Installing uv Package Manager
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub102.md
Provides installation commands for the Rust-based Python package manager across different platforms.
```bash
# On macOS and Linux.
$ curl -LsSf https://astral.sh/uv/install.sh | sh
# On Windows.
$ powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# With pip.
$ pip install uv
```
--------------------------------
### Run Jenkins CI/CD server
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub80.md
Steps to download and execute the Jenkins JAR file to start the CI/CD server.
```shell
1. 下载 jar 包
2. 运行:java -jar jenkins.war --httpPort=8080
3. 打开浏览器访问:http://localhost:8080
4. 根据提示完成安装
```
--------------------------------
### Install Goalert via Docker
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub39.md
Command to run the Goalert all-in-one container on port 8081.
```bash
docker run -it --rm -p 8081:8081 goalert/all-in-one
访问本地 8081 端口,用户名 admin,密码 admin123
```
--------------------------------
### Install Glances System Monitor
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub09.md
Command to install the Glances system monitoring tool via pip.
```bash
pip install glances
```
--------------------------------
### Create CLI Applications with Click
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/en/HelloGitHub34.md
Use decorators to define command-line options and arguments. The example demonstrates a greeting program with configurable count and name inputs.
```python
import click
@click.command()
@click.option("--count", default=1, help="Number of greetings.")
@click.option("--name", prompt="Your name",
help="The person to greet.")
def hello(count, name):
"""Simple program that greets NAME for a total of COUNT times."""
for _ in range(count):
click.echo("Hello, %s!" % name)
if __name__ == '__main__':
hello()
# 下面为运行效果
$ python hello.py --count=3
Your name: Click
Hello, Click!
Hello, Click!
Hello, Click!
```
--------------------------------
### xLua Script Execution Example
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub66.md
Demonstrates initializing the Lua environment and executing a simple Lua string within a C# context.
```csharp
XLua.LuaEnv luaenv = new XLua.LuaEnv();
luaenv.DoString("CS.UnityEngine.Debug.Log('hello world')");
luaenv.Dispose();
```
--------------------------------
### Implementing an RPC Service with srpc
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub56.md
Shows how to define a service implementation and start an RPC server using the srpc framework, followed by a curl command for testing.
```C++
class ExampleServiceImpl : public Example::Service
{
public:
void Echo(EchoRequest *request, EchoResponse *response, RPCContext *ctx) override
{
response->set_message("Hi, " + request->name());
}
};
int main()
{
SRPCHttpServer server;
ExampleServiceImpl impl;
server.add_service(&impl);
server.start(1412);
pause();
server.stop();
return 0;
}
访问:
curl 127.0.0.1:1412/Example/Echo -H 'Content-Type: application/json' -d '{message:"from curl",name:"CURL"}'
```
--------------------------------
### SQL Style Comparison
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub57.md
Examples demonstrating preferred versus discouraged SQL syntax for string quoting.
```sql
-- Good
select *
from users
where email = 'example@domain.com'
-- Bad
select *
from users
where email = "example@domain.com"
```
--------------------------------
### 解析地址字符串为结构化数据
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub112.md
使用 libpostal 库解析地址字符串,需在程序开始时调用 setup 函数并在结束时调用 teardown 函数。
```c
#include
#include
#include
int main(int argc, char **argv) {
// Setup (only called once at the beginning of your program)
if (!libpostal_setup() || !libpostal_setup_parser()) {
exit(EXIT_FAILURE);
}
libpostal_address_parser_options_t options = libpostal_get_address_parser_default_options();
libpostal_address_parser_response_t *parsed = libpostal_parse_address("781 Franklin Ave Crown Heights Brooklyn NYC NY 11216 USA", options);
for (size_t i = 0; i < parsed->num_components; i++) {
printf("%s: %s\n", parsed->labels[i], parsed->components[i]);
}
// Free parse result
libpostal_address_parser_response_destroy(parsed);
// Teardown (only called once at the end of your program)
libpostal_teardown();
libpostal_teardown_parser();
}
```
--------------------------------
### Initialize and run a jwEngine server
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub60.md
Demonstrates setting up a basic network server using the jwEngine framework with Lua scripting.
```lua
event_init()
server = NetServer:new()
server.on_accept = function(conn)
end
server.on_close = function(conn)
end
server.on_msg = function(conn, msgtype, pack)
end
server:listen("127.0.0.1", 3001, false)
event_run()
```
--------------------------------
### Run the bot script
Source: https://github.com/521xueweihan/hellogithub/blob/master/script/github_bot/README.md
Execute the main script to start the data collection process.
```bash
python github_bot.py
```
--------------------------------
### Deploy Shifu IoT Framework
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub82.md
Install the Shifu IoT platform into a Kubernetes cluster.
```shell
cd shifu
# 在集群中安装 Shifu
kubectl apply -f pkg/k8s/crd/install/shifu_install.yml
```
--------------------------------
### Run a Linux container with barco
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub89.md
Example command to initialize and run a container using the barco tool, followed by shell interaction inside the container.
```bash
$ sudo ./bin/barco -u 0 -m / -c /bin/sh -a . [-v]
22:08:41 INFO ./src/barco.c:96: initializing socket pair...
22:08:41 INFO ./src/barco.c:103: setting socket flags...
22:08:41 INFO ./src/barco.c:112: initializing container stack...
22:08:41 INFO ./src/barco.c:120: initializing container...
22:08:41 INFO ./src/barco.c:131: initializing cgroups...
22:08:41 INFO ./src/cgroups.c:73: setting memory.max to 1G...
22:08:41 INFO ./src/cgroups.c:73: setting cpu.weight to 256...
22:08:41 INFO ./src/cgroups.c:73: setting pids.max to 64...
22:08:41 INFO ./src/cgroups.c:73: setting cgroup.procs to 1458...
22:08:41 INFO ./src/barco.c:139: configuring user namespace...
22:08:41 INFO ./src/barco.c:147: waiting for container to exit...
22:08:41 INFO ./src/container.c:43: ### BARCONTAINER STARTING - type 'exit' to quit ###
# ls
bin home lib32 media root sys vmlinuz
boot initrd.img lib64 mnt run tmp vmlinuz.old
dev initrd.img.old libx32 opt sbin usr
etc lib lost+found proc srv var
# echo "i am a container"
i am a container
```
--------------------------------
### Fetch Latest Software Versions with lastversion
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub58.md
Command-line usage examples for retrieving the latest version tags for specified software packages.
```bash
# 获取最新的 Linux 版本号和最新的 Wordpress 版本号
lastversion linux
# 作者的版本标签:v5.10
# 本项目提供的版本标签:5.10
lastversion wordpress
# 作者的版本标签:5.6
# 本项目提供的版本标签:5.6
```
--------------------------------
### Interact with gRPC Services using grpcurl
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub82.md
Install and use grpcurl to perform requests against gRPC servers.
```shell
# 安装
brew install grpcurl
# 使用
grpcurl grpc.server.com:443 my.custom.server.Service/Method
```
--------------------------------
### Interact with MySQL using PyMySQL
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub08.md
Example demonstrating how to connect to a database, insert records, and query data using PyMySQL.
```python
# -*- coding: utf-8 -*-
import pymysql.cursors
# 连接数据库
connection = pymysql.connect(host='localhost',
user='user',
password='passwd',
db='db',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
try:
with connection.cursor() as cursor:
# 创建一个新的纪录(record)
sql = "INSERT INTO `users` (`email`, `password`) VALUES (%s, %s)"
cursor.execute(sql, ('webmaster@python.org', 'very-secret'))
# 连接不会自动提交,所以你想下面要调用 commit 方法,存储对数据库的改动
connection.commit()
with connection.cursor() as cursor:
sql = "SELECT `id`, `password` FROM `users` WHERE `email`=%s"
cursor.execute(sql, ('webmaster@python.org',))
# 获取一条的纪录(record)
result = cursor.fetchone()
print(result) # 结果输出:{'password': 'very-secret', 'id': 1}
finally:
connection.close() # 操作完数据库一要记得调用 close 方法,关闭连接
```
--------------------------------
### Create a Web Route with Vapor in Swift
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub71.md
Sets up a basic Vapor application and defines a GET route that returns a 'Hello, world.' string.
```swift
import Vapor
let app = try Application(.detect())
defer { app.shutdown() }
app.get("hello") { req in
return "Hello, world."
}
try app.run()
```
--------------------------------
### Initialize and Configure Leaflet Map
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub67.md
Demonstrates basic map initialization, tile layer setup, and marker placement with a popup.
```javascript
var map = L.map('map').setView([51.505, -0.09], 13);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '©OpenStreetMap contributors'
}).addTo(map);
L.marker([51.5, -0.09]).addTo(map)
.bindPopup('A pretty CSS3 popup.
Easily customizable.')
.openPopup();
```
--------------------------------
### Manage Go Versions with GVM
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub06.md
Commands for installing, configuring, and using the Go Version Manager (GVM) to switch between different Go environments.
```bash
1. 安装gvm:bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
2. 根据提示,在shell配置中加入:source /PATH/.gvm/scripts/gvm
3. 以下为常用命令:
gvm install go1.4 # 安装制定版本的GO
gvm use go1.4 # 使用制定版本的GO
4. Mac下安装Go时如果出现错误,就安装依赖的库:
xcode-select --install
brew update
brew install mercurial
5. 我在使用中发现的问题:
安装Go时没有进度条
```
--------------------------------
### Analyze Python Performance with VizTracer
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub105.md
Install the tool, generate a performance report for a script, and visualize the results.
```bash
# 安装
pip install viztracer
# 生成分析报告
viztracer my_script.py arg1 arg2
# 可视化查看报告
vizviewer result.json
```
--------------------------------
### Create an HTTP server with libhv
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub48.md
Demonstrates setting up a basic HTTP server with a defined API endpoint using the libhv library.
```cpp
#include "HttpServer.h"
int http_api_echo(HttpRequest* req, HttpResponse* res) {
res->body = req->body;
return 0;
}
int main() {
HttpService service;
service.base_url = "/v1/api";
service.AddApi("/echo", HTTP_POST, http_api_echo);
http_server_t server;
server.port = 8080;
server.service = &service;
http_server_run(&server);
return 0;
}
```
--------------------------------
### Configure Local HTTPS with mkcert
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub44.md
Use these commands to install a local CA and generate certificates for development environments.
```bash
$ mkcert -install
Created a new local CA at "/Users/filippo/Library/Application Support/mkcert" 💥
The local CA is now installed in the system trust store! ⚡️
The local CA is now installed in the Firefox trust store (requires browser restart)! 🦊
$ mkcert example.com "*.example.com" example.test localhost 127.0.0.1 ::1
Using the local CA at "/Users/filippo/Library/Application Support/mkcert" ✨
Created a new certificate valid for the following names 📜
- "example.com"
- "*.example.com"
- "example.test"
- "localhost"
- "127.0.0.1"
- "::1"
The certificate is at "./example.com+5.pem" and the key at "./example.com+5-key.pem" ✅
```
--------------------------------
### Launch pgweb with connection parameters
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub54.md
Demonstrates different methods to connect to a PostgreSQL database using pgweb via command-line arguments, connection strings, or Unix sockets.
```bash
三种方式:
参数:pgweb --host localhost --user myuser --db mydb
URL:pgweb --url postgres://user:password@host:port/database?sslmode=[mode]
Socket:pgweb --url "postgres:///database?host=/absolute/path/to/unix/socket/dir"
```
--------------------------------
### Share Terminal Sessions with termpair
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub65.md
Install the package via pip, start the server, and generate a shareable link for remote terminal access.
```bash
# 安装
pip install termpair
# 起服务
termpair serve
# 生成远程控制终端的链接
termpair share
```
--------------------------------
### Managing Application Settings with Mackup
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub77.md
Basic shell commands for installing, backing up, and restoring application configurations using Mackup.
```shell
# 安装
brew install mackup
# 备份
mackup backup
# 恢复
mackup restore
```
--------------------------------
### Create and Configure Word Document with Unioffice
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub39.md
Initializes a new document and sets the background color using RGB values.
```go
dox := document.New()
doc.X().Background = wordprocessingml.NewCT_Background()
doc.X().Background.ColorAttr = &wordprocessingml.ST_HexColor{}
doc.X().Background.ColorAttr.ST_HexColorRGB = color.RGB(50, 50, 50).AsRGBString()
```
--------------------------------
### Install and Launch Weave Scope
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub40.md
Shell commands to download, set permissions, and launch the Scope container visualization tool.
```bash
# 安装
sudo curl -L git.io/scope -o /usr/local/bin/scope
sudo chmod a+x /usr/local/bin/scope
scope launch
# 最后访问 http://localhost:4040
```
--------------------------------
### Interact with Databases using sqlx
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub97.md
Establish a connection pool and execute asynchronous queries in Rust. This example demonstrates a PostgreSQL connection and a simple query execution.
```rust
use sqlx::postgres::PgPoolOptions;
// use sqlx::mysql::MySqlPoolOptions;
// etc.
#[async_std::main] // Requires the `attributes` feature of `async-std`
// or #[tokio::main]
// or #[actix_web::main]
async fn main() -> Result<(), sqlx::Error> {
// Create a connection pool
// for MySQL/MariaDB, use MySqlPoolOptions::new()
// for SQLite, use SqlitePoolOptions::new()
// etc.
let pool = PgPoolOptions::new()
.max_connections(5)
.connect("postgres://postgres:password@localhost/test").await?;
// Make a simple query to return the given parameter (use a question mark `?` instead of `$1` for MySQL/MariaDB)
let row: (i64,) = sqlx::query_as("SELECT $1")
.bind(150_i64)
.fetch_one(&pool).await?;
assert_eq!(row.0, 150);
Ok(())
}
```
--------------------------------
### Install and Use Spleeter for Audio Separation
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub69.md
Provides shell commands to install dependencies via conda, install the library via pip, and execute audio track separation.
```bash
# 用 conda 安装依赖
conda install -c conda-forge ffmpeg libsndfile
# 用 pip 安装 spleeter
pip install spleeter
# 提取人声
spleeter separate -p spleeter:2stems -o output 音频.mp3
```
--------------------------------
### Minilisp Code Example
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub69.md
Demonstrates basic Lisp syntax including printing, arithmetic, variable definition, and usage within the minilisp interpreter.
```lisp
(println 3) ; prints "3"
(+ 1 2 3) ; -> 6
(define a (+ 1 2))
(+ a a) ; -> 6
```
--------------------------------
### Configure Concurrency Limits in Java
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub75.md
Example of setting up adaptive concurrency limits using the Netflix concurrency-limits library with a gRPC server interceptor.
```java
// Create and configure a server builder
ServerBuilder builder = ...;
builder.addService(ServerInterceptor.intercept(service,
ConcurrencyLimitServerInterceptor.newBuilder(
new GrpcServerLimiterBuilder()
.partitionByHeader(GROUP_HEADER)
.partition("live", 0.9)
.partition("batch", 0.1)
.limit(WindowedLimit.newBuilder()
.build(Gradient2Limit.newBuilder()
.build()))
.build();
));
```
--------------------------------
### Configure django-grappelli for Admin Interface
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub70.md
Install and configure the library in a Django project by updating settings and URL patterns.
```python
# 安装
pip install django-grappelli
# 设置 settings.py 文件
INSTALLED_APPS = (
'grappelli',
'django.contrib.admin',
)
# 增加路径
urlpatterns = [
path('grappelli/', include('grappelli.urls')), # grappelli URLS
path('admin/', admin.site.urls), # admin site
]
# 增加请求处理器
TEMPLATES = [
...
'OPTIONS': {
'context_processors': [
...
'django.template.context_processors.request',
...
]
# 最后
python manage.py collectstatic
```
--------------------------------
### Query Data Sources with octosql
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub70.md
Examples of using octosql to perform SQL queries on local files and databases.
```bash
octosql "SELECT * FROM ./myfile.json"
octosql "SELECT * FROM ./myfile.json" --describe # Show the schema of the file.
octosql "SELECT invoices.id, address, amount
FROM invoices.csv JOIN db.customers ON invoices.customer_id = customers.id
ORDER BY amount DESC"
octosql "SELECT customer_id, SUM(amount)
FROM invoices.csv
GROUP BY customer_id"
```
--------------------------------
### Initialize and use haipproxy client
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub24.md
Demonstrates how to connect to a Redis-backed proxy pool and retrieve available proxy IPs for specific target websites.
```python
from client.py_cli import ProxyFetcher
args = dict(host='127.0.0.1', port=6379, password='123456', db=0)
# 这里`zhihu`的意思是,去和`zhihu`相关的代理ip校验队列中获取ip
# 这么做的原因是同一个代理IP对不同网站代理效果不同
fetcher = ProxyFetcher('zhihu', strategy='greedy', redis_args=args)
# 获取一个可用代理
print(fetcher.get_proxy())
# 获取可用代理列表
print(fetcher.get_proxies()) # or print(fetcher.pool)
```
--------------------------------
### Setup and Run LocalAI
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub86.md
Commands to clone, configure, and launch the LocalAI service using Docker Compose, including verification via curl requests.
```bash
# Clone LocalAI
git clone https://github.com/go-skynet/LocalAI
cd LocalAI
# (optional) Checkout a specific LocalAI tag
# git checkout -b build
# Download gpt4all-j to models/
wget https://gpt4all.io/models/ggml-gpt4all-j.bin -O models/ggml-gpt4all-j
# Use a template from the examples
cp -rf prompt-templates/ggml-gpt4all-j.tmpl models/
# (optional) Edit the .env file to set things like context size and threads
# vim .env
# start with docker-compose
docker-compose up -d --pull always
# or you can build the images with:
# docker-compose up -d --build
# Now API is accessible at localhost:8080
curl http://localhost:8080/v1/models
# {"object":"list","data":[{"id":"ggml-gpt4all-j","object":"model"}]}
curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d '{
"model": "ggml-gpt4all-j",
"messages": [{"role": "user", "content": "How are you?"}],
"temperature": 0.9
}'
# {"model":"ggml-gpt4all-j","choices":[{"message":{"role":"assistant","content":"I'm doing well, thanks. How about you?"}}]}
```
--------------------------------
### Initialize PixiJS Application
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub121.md
Demonstrates setting up a PixiJS application, loading a texture, and adding an animated sprite to the stage.
```typescript
import { Application, Assets, Sprite } from 'pixi.js';
(async ()
{
// Create a new application
const app = new Application();
// Initialize the application
await app.init({ background: '#1099bb', resizeTo: window });
// Append the application canvas to the document body
document.body.appendChild(app.canvas);
// Load the bunny texture
const texture = await Assets.load('https://pixijs.com/assets/bunny.png');
// Create a bunny Sprite
const bunny = new Sprite(texture);
// Center the sprite's anchor point
bunny.anchor.set(0.5);
// Move the sprite to the center of the screen
bunny.x = app.screen.width / 2;
bunny.y = app.screen.height / 2;
app.stage.addChild(bunny);
// Listen for animate update
app.ticker.add((time) =>
{
// Just for fun, let's rotate mr rabbit a little.
// * Delta is 1 if running at 100% performance *
// * Creates frame-independent transformation *
bunny.rotation += 0.1 * time.deltaTime;
});
})();
```
--------------------------------
### Run filebrowser with Docker
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub30.md
Use this command to start the filebrowser container with volume mappings for site root, configuration, and database files.
```bash
docker run \
-v /path/to/sites/root:/srv \
-v /path/to/config.json:/config.json \
-v /path/to/database.db:/database.db \
-p 80:80 \
filebrowser/filebrowser
```
--------------------------------
### Capture Video with gocv
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub95.md
Initialize a webcam stream and display frames in a GUI window using the gocv wrapper for OpenCV. Ensure OpenCV is installed on the host system.
```go
package main
import (
"gocv.io/x/gocv"
)
func main() {
// 打开摄像头
webcam, _ := gocv.OpenVideoCapture(0)
// 新建 GUI 窗口
window := gocv.NewWindow("Hello")
img := gocv.NewMat()
// 显示视频
for {
webcam.Read(&img)
window.IMShow(img)
window.WaitKey(1)
}
}
```
--------------------------------
### Create a Native Desktop App with Toga
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub108.md
Build a cross-platform GUI application using the Toga framework. Requires the toga library to be installed.
```python
import toga
def button_handler(widget):
print("hello")
def build(app):
box = toga.Box()
button = toga.Button("Hello world", on_press=button_handler, style={"margin": 50, "flex": 1})
box.add(button)
return box
def main():
return toga.App("First App", "org.beeware.toga.examples.tutorial", startup=build)
if __name__ == "__main__":
main().main_loop()
```
--------------------------------
### Manage Video Downloads with youtube-dl
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub21.md
Provides common commands for installing, listing formats, and downloading videos using the youtube-dl utility.
```bash
# 1. 安装命令:sudo pip install youtube-dl
Installing collected packages: youtube-dl
Successfully installed youtube-dl-2017.12.14
# 2. 查看 URL 支持格式:youtube-dl --list-formats URL
format code extension resolution note
134 mp4 450x360 DASH video 449k , avc1.4d4015, 25fps, video only
17 3gp 176x144 small , mp4v.20.3, mp4a.40.2@ 24k
36 3gp 300x240 small , mp4v.20.3, mp4a.40.2
18 mp4 450x360 medium , avc1.42001E, mp4a.40.2@ 96k
43 webm 640x360 medium , vp8.0, vorbis@128k (best)
# 3. 选择格式下载视频:youtube-dl -f 18 URL (18为mp4 450x360格式)
[youtube:playlist] Downloading playlist PLF90USSyuoYzPhhFG7XFBRn63Zvs--lNP - add --no-playlist to just download video JyLducMVYVg
[youtube:playlist] PLF90USSyuoYzPhhFG7XFBRn63Zvs--lNP: Downloading webpage
[download] Downloading playlist: 情满四合院完整版
[youtube:playlist] playlist 情满四合院完整版: Downloading 42 videos
[download] Downloading video 1 of 42
...
# 4. 下载完成后,最后使用 https://github.com/houtianze/bypy 库把下载的视频同步到百度网盘上
```
--------------------------------
### Install and Manage Dgraph
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub29.md
Use the provided curl command to install the Dgraph distributed graph database.
```bash
curl https://get.dgraph.io -sSf | bash
```
--------------------------------
### Initialize Geziyor Crawler
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub39.md
Configures a new Geziyor instance with start URLs and a JSON exporter to process scraped data.
```go
func main() {
geziyor.NewGeziyor(&geziyor.Options{
StartURLs: []string{"http://quotes.toscrape.com/"},
ParseFunc: quotesParse,
// exporter 可以用来把最终结果存成各种格式,例如 json
Exporters: []geziyor.Exporter{exporter.JSONExporter{}},
}).Start()
}
// 请求的结果直接进了一个管道处理函数,这样的函数可以串联起来,爬虫和清洗二合一
// 这样拆分爬虫逻辑,某些逻辑也可以重用
func quotesParse(g *geziyor.Geziyor, r *geziyor.Response) {
r.HTMLDoc.Find("div.quote").Each(func(i int, s *goquery.Selection) {
g.Exports <- map[string]interface{}{
"text": s.Find("span.text").Text(),
"author": s.Find("small.author").Text(),
}
})
if href, ok := r.HTMLDoc.Find("li.next > a").Attr("href"); ok {
g.Get(r.JoinURL(href), quotesParse)
}
}
```
--------------------------------
### Implement Quantitative Trading with Tqsdk
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub64.md
Shows how to create a TqApi instance and manage target positions for futures contracts based on price spread calculations.
```python
from tqsdk import TqApi, TqAuth, TqAccount, TargetPosTask
api = TqApi(TqAccount("H海通期货", "4003242", "123456"), auth=TqAuth("信易账户", "账户密码")) # 创建 TqApi 实例, 指定交易账户
q_1910 = api.get_quote("SHFE.rb1910") # 订阅近月合约行情
t_1910 = TargetPosTask(api, "SHFE.rb1910") # 创建近月合约调仓工具
q_2001 = api.get_quote("SHFE.rb2001") # 订阅远月合约行情
t_2001 = TargetPosTask(api, "SHFE.rb2001") # 创建远月合约调仓工具
while True:
api.wait_update() # 等待数据更新
spread = q_1910.last_price - q_2001.last_price # 计算近月合约-远月合约价差
print("当前价差:", spread)
if spread > 250:
print("价差过高: 空近月,多远月")
t_1910.set_target_volume(-1) # 要求把1910合约调整为空头1手
t_2001.set_target_volume(1) # 要求把2001合约调整为多头1手
elif spread < 200:
print("价差回复: 清空持仓") # 要求把 1910 和 2001合约都调整为不持仓
t_1910.set_target_volume(0)
t_2001.set_target_volume(0)
```
--------------------------------
### Logging with spdlog
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub56.md
Demonstrates basic logging, formatting, log level configuration, and pattern customization using the spdlog C++ library.
```C++
#include "spdlog/spdlog.h"
int main()
{
spdlog::info("Welcome to spdlog!");
spdlog::error("Some error message with arg: {}", 1);
spdlog::warn("Easy padding in numbers like {:08d}", 12);
spdlog::critical("Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
spdlog::info("Support for floats {:03.2f}", 1.23456);
spdlog::info("Positional args are {1} {0}..", "too", "supported");
spdlog::info("{:<30}", "left aligned");
spdlog::set_level(spdlog::level::debug); // Set global log level to debug
spdlog::debug("This message should be displayed..");
// change log pattern
spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");
// Compile time log levels
// define SPDLOG_ACTIVE_LEVEL to desired level
SPDLOG_TRACE("Some trace message with param {}", 42);
SPDLOG_DEBUG("Some debug message");
}
```
--------------------------------
### Install freeze via Package Managers
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub97.md
Commands to install the freeze terminal tool on various operating systems.
```bash
# macOS or Linux
brew install charmbracelet/tap/freeze
# Arch Linux (btw)
pacman -S freeze
# Nix
nix-env -iA nixpkgs.charm-freeze
```
--------------------------------
### Configure HTTP Routing with Gorilla Mux
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub40.md
Demonstrates initializing a router and defining various URL patterns including regex matching and path variables.
```go
func main() {
r := mux.NewRouter()
r.HandleFunc("/", HomeHandler)
r.HandleFunc("/products", ProductsHandler)
r.HandleFunc("/articles", ArticlesHandler)
http.Handle("/", r)
}
r := mux.NewRouter()
r.HandleFunc("/products/{key}", ProductHandler)
r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
```
--------------------------------
### Install IINA via Homebrew
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub24.md
Command to install the IINA media player on macOS using Homebrew Cask.
```bash
brew cask install iina
```
--------------------------------
### Run pokete terminal game
Source: https://github.com/521xueweihan/hellogithub/blob/master/content/HelloGitHub72.md
Commands to install dependencies and execute the pokete terminal game.
```bash
运行方法:
# pip install scrap_engine
$ git clone https://github.com/lxgr-linux/pokete.git
$ ./pokete/pokete.py
```