Skip to content

Instantly share code, notes, and snippets.

@RussellLuo
RussellLuo / grpc_pi.py
Last active April 15, 2020 10:35
gRPC client interface for Python: generation script and mocking class.
# -*- coding=utf-8 -*-
"""Generate a pythonic interface based on the code generated by `grpcio-tools`.
Example:
$ python grpc_pi.py --proto-package-name='xx' --pb2-module-name='python.path.xx_pb2'
"""
import argparse
import itertools
@RussellLuo
RussellLuo / httpclient.go
Created May 27, 2020 08:16
An HTTP client creator for Golang
package httpclient
import (
"net"
"net/http"
"time"
)
// Options includes common Client configurations that need to be tuned.
type Options struct {
@RussellLuo
RussellLuo / werror.go
Created May 28, 2020 08:08
Enhanced error handling based on new features introduced in Go 1.13
package werror
import (
"fmt"
)
type Error struct {
Err error // the underlying error
Str string
}
@RussellLuo
RussellLuo / appx_gin_example.go
Last active June 10, 2021 13:10
An example illustrates how to manage Gin-based HTTP applications in appx.
package main
import (
"context"
"fmt"
"net/http"
"github.com/RussellLuo/appx"
"github.com/gin-gonic/gin"
)
@RussellLuo
RussellLuo / gst_jpeg_encoder.py
Last active April 25, 2022 12:34
JPEG encoder based on gstreamer.
# -*- coding: utf-8 -*-
"""
JPEG encoder based on gstreamer.
Many thanks to the following code and docs:
- The usage of `appsrc` in Python: https://github.com/tamaggo/gstreamer-examples/blob/master/test_gst_appsrc_testvideo_mp4mux.py
- The usage of `appsink` in Python: https://gist.github.com/willpatera/7984486
- The usage of both `appsrc` and `appsink` in C++: https://github.com/dkorobkov/gstreamer-appsrc-appsink-example/blob/master/JpegGstEncoder.cpp