JERRYLSU

Concurrent http requests using asyncio and aiohttp
by Jerry Su, post on Jul 13, 2023

import aiohttp
import asyncio
from typing import Dict
async def async_post_request(url: str, data: Dict) -> Dict:
    """async post.
    """
    async with aiohttp.ClientSession() as session:
        async with session.post(url, json=data) as resp:
            response = await resp.json()
    return response
model_url_dict={
    "scene1": "http://0.0.0.0:8781/classify/utcx",
    "scene2 …

Read in 1 mins
Rust closure
by Jerry Su, post on Jan 05, 2023

闭包:可以捕获其所在作用域中变量的匿名函数

fn  add_one_v1   (x: u32) -> u32 { x + 1 };
let add_one_v2 = |x: u32| -> u32 { x + 1 };
let add_one_v3 = |x|             { x + 1 };
let add_one_v4 = |x|               x + 1  ;
  • 调用方式与函 …

Read in 1 mins
Rust self vs &self vs &mut self
by Jerry Su, post on Jan 05, 2023

  • self: (self: Self) Having a method that takes ownership of the instance by using just self as the first parameter is rare; this technique is usually used when the method transforms self into something else and you want to prevent the caller from using the original instance after the transformation …

Read in 1 mins
Rust in JupyterLab
by Jerry Su, post on Dec 20, 2022

1.Install JupyterLab
2.Install Rust
  • curl https://sh.rustup.rs -sSf | sh

  • source $HOME/.cargo/env

  • export PATH="$HOME/.cargo/bin:$PATH"

3.Install Evcxr Jupyter Kernel
  • cargo install evcxr_jupyter

  • evcxr_jupyter --install

4.Reference

https://github.com/google/evcxr/blob/main/evcxr_jupyter/README.md

https://datacrayon.com/posts/programming …

Read in 1 mins
Python docx using lxml
by Jerry Su, post on Sep 25, 2022

Reason is the light and the light of life.

Read in 9 mins
Multiprocessing in FastAPI
by Jerry Su, post on Jul 28, 2022

Reason is the light and the light of life.

Read in 1 mins
asyncio get_event_loop vs get_running_loop
by Jerry Su, post on Jul 28, 2022

Reason is the light and the light of life.

Read in 1 mins
FastAPI for CPU-Bound Task
by Jerry Su, post on Jul 19, 2022

Reason is the light and the light of life.

Read in 1 mins
Base64-encode-decode
by Jerry Su, post on May 09, 2022

Reason is the light and the light of life.

Read in 1 mins