Skip to content

Instantly share code, notes, and snippets.

@RussellLuo
RussellLuo / gst_jpeg_encoder.py
Last active April 8, 2025 14:55
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"
)
@RussellLuo
RussellLuo / mitmproxy_jsonl_viewer.py
Created September 4, 2025 07:30
mitmproxy-addon-for-claude-code
"""
Write request and response data to a JSONL file.
This script demonstrates how to capture HTTP request and response data and write them
to a JSONL (JSON Lines) file format. Each request-response pair is written as a
single JSON object on its own line, making it easy to process complete HTTP flow data.
"""
import json
import os