Skip to content

Instantly share code, notes, and snippets.

View Renkai's full-sized avatar
🤓
提升姿势水平中

Renkai Ge Renkai

🤓
提升姿势水平中
View GitHub Profile
@Renkai
Renkai / pip.md
Last active November 30, 2020 02:37
PIP: Configurable data source priority for offloaded messages

Motivation

Currently, if the data in pulsar was offloaded to the second storage layer, data can still exists in bookkeeper for a period of time, but the client will directly read data from the second layer.

This may lead to several problems:

  • Read from second layer have different performance characteristics, which may lead wrong estimate from users if they didn't know which layer they are reading.
  • The second layer may be managed by another team rather than Pulsar management team(for example, a independent HDFS management team), they may have independent quota or authority policy to users.
  • The second layer storage can be infinite in theory, if user set cursor to an error time in accident, it will cause a lot of resource waste.
@Renkai
Renkai / rm_outdated_m2.sh
Created December 3, 2020 01:48
remove outdated m2 cache
find ~/.m2/repository/ -atime +1 -iname '*.pom' -print0 | while read -d '' -r pom; do echo rm -rf "$(dirname $pom)"; done
@Renkai
Renkai / timed_flow.scala
Created April 6, 2021 13:25
Demo to measure time consumption of a flow
object TimedFlow {
def apply[In, Out](innerFlow: Flow[In, Out, NotUsed], func: (Long, Long) => Any): Flow[In, Out, NotUsed] = {
val flowWithLong = Flow.fromGraph(GraphDSL.create() {
implicit builder =>
import akka.stream.scaladsl.GraphDSL.Implicits._
val unzip = builder.add(Unzip[In, Long]())
val zip = builder.add(Zip[Out, Long]())
unzip.out0 ~> innerFlow ~> zip.in0
unzip.out1 ~> zip.in1
@Renkai
Renkai / method_from_name.py
Created April 24, 2022 08:39
python run method from name
import base64
import json
import sys
demo_obj = {
'module_name': "spock_spore_engine.tasks.demo_task",
'class_name': "DemoTask",
'class_args': [],
'class_kwargs': {
@Renkai
Renkai / bilibili_cache_converter.py
Last active April 29, 2023 09:15
Convert your bilibili local cache to mp4
import subprocess
import shlex
import json
import sys
from pathlib import Path
from numpy import fromfile, uint8 # pip install numpy
ROOT = Path(sys.argv[0]).resolve().parent
for dir in ROOT.iterdir():
if not dir.name.startswith("22"):