Skip to content

Instantly share code, notes, and snippets.

Oh my zsh.

Oh My Zsh

Install ZSH.

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh

Install Oh my ZSH.

//! The HTTP request method
//!
//! This module contains HTTP-method related structs and errors and such. The
//! main type of this module, `Method`, is also reexported at the root of the
//! crate as `http::Method` and is intended for import through that location
//! primarily.
//!
//! # Examples
//!
//! ```
/// Converts a slice of bytes to an HTTP method.
pub fn from_bytes(src: &[u8]) -> Result<Method, InvalidMethod> {
match src.len() {
0 => Err(InvalidMethod::new()),
3 => match src {
b"GET" => Ok(Method(Get)),
b"PUT" => Ok(Method(Put)),
_ => Method::extension_inline(src),
},
4 => match src {
@xcuzalex
xcuzalex / format.py
Created February 17, 2022 04:21
python-format
# %% 位置
print("{0} {1}".format("hello", "world"))
print("{} {}".format("hello", "world"))
print("{1} {0} {1}".format("hello", "world"))
# %% 关键字
print("I am {name}, age is {age}".format(name="huoty", age=18))
user = {"name": "huoty", "age": 18}
"I am {name}, age is {age}".format(**user)
@xcuzalex
xcuzalex / py_kudu.py
Created February 17, 2022 03:58
python-kudu
import kudu
from kudu.client import Partitioning
from datetime import datetime
# Connect to Kudu master server
client = kudu.connect(host='localhost', port=7051)
# Define a schema for a new table
builder = kudu.schema_builder()
builder.add_column('key').type(kudu.int64).nullable(False).primary_key()
@xcuzalex
xcuzalex / snowflake.py
Created February 17, 2022 03:47
python-snowflake
#!/usr/bin/env python3
import time
from uuid import getnode as get_mac
import flask
"""
基于twitter的雪花算法生成不重复,且具有自增的流水号
该算法参考 https://github.com/twitter/snowflake
"""
app = flask.Flask(__name__)
@xcuzalex
xcuzalex / mqtt_acl.py
Created February 17, 2022 03:42
python-mqtt
import asyncio
from asyncio_mqtt import Client
import time
import uvloop
import sys
topic = "topic"
topic1 = "topic1"
topic2 = "topic2"
topic3 = "topic3"