Skip to content

Instantly share code, notes, and snippets.

@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
@RussellLuo
RussellLuo / base_encoder.py
Created February 7, 2020 05:13
An encoder that can encode a decimal number to a string in any base, and vice versa.
class BaseEncoder:
"""
An encoder that can encode a decimal number to a string in any base, and vice versa.
Example usage:
>>> import string
>>> chars_62 = string.digits + string.ascii_letters[:52]
>>> encoder = BaseEncoder(chars_62)
>>> encoder.encode(10765432100123456789)
@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"
)