Skip to content

Instantly share code, notes, and snippets.

View rich840213's full-sized avatar
🐮

Fu-Sheng rich840213

🐮
View GitHub Profile
@rich840213
rich840213 / example.proto
Created October 13, 2022 06:14 — forked from miguelmota/example.proto
Golang protobuf marshal and unmarshal example
syntax = "proto3";
message Message {
bytes text = 1;
}
@rich840213
rich840213 / golang_prometheus_metric_counter.go
Created September 21, 2022 02:33 — forked from ggzeng/golang_prometheus_metric_counter.go
prometheus golang 客户端中的各类metric写法
//step1:初始一个counter, with help string
pushCounter = prometheus.NewCounter(prometheus.CounterOpts{
Name: "repository_pushes",
Help: "Number of pushes to external repository.",
})
//setp2: 注册容器
err = prometheus.Register(pushCounter)
if err != nil {
fmt.Println("Push counter couldn't be registered AGAIN, no counting will happen:", err)
@rich840213
rich840213 / Event.kt
Created March 5, 2021 01:06 — forked from JoseAlcerreca/Event.kt
An event wrapper for data that is exposed via a LiveData that represents an event.
/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
/**
* Returns the content and prevents its use again.
@rich840213
rich840213 / EventObserver.kt
Created March 5, 2021 01:05 — forked from JoseAlcerreca/EventObserver.kt
An Observer for Events, simplifying the pattern of checking if the Event's content has already been handled.
/**
* An [Observer] for [Event]s, simplifying the pattern of checking if the [Event]'s content has
* already been handled.
*
* [onEventUnhandledContent] is *only* called if the [Event]'s contents has not been handled.
*/
class EventObserver<T>(private val onEventUnhandledContent: (T) -> Unit) : Observer<Event<T>> {
override fun onChanged(event: Event<T>?) {
event?.getContentIfNotHandled()?.let { value ->
onEventUnhandledContent(value)
@rich840213
rich840213 / gist:e38a609b0ecb60d17c452488209446b7
Created June 5, 2020 06:49 — forked from davepoon/gist:4371622
Added the .gitignore, and refresh the file index so the files get ignored properly.
git rm -r --cached .
git add .
git commit -m ".gitignore is now working"
@rich840213
rich840213 / git_remote_set-url.md
Created June 5, 2020 06:48 — forked from fokayx/git_remote_set-url.md
Git switch remote URLs. Git 更換遠端伺服器倉庫網址

Git 更換遠端伺服器倉庫網址URL

1.確認目前Git遠端伺服器網址: git remote -v

git remote -v
origin  https://github.com/USERNAME/REPOSITORY.git (fetch)
origin  https://github.com/USERNAME/REPOSITORY.git (push)

2.更換Git遠端伺服器位網址,使用:git remote set-url

@rich840213
rich840213 / Remove all git tags
Created June 2, 2020 08:39 — forked from okunishinishi/Remove all git tags
Delete all git remote tags
#Delete local tags.
git tag -l | xargs git tag -d
#Fetch remote tags.
git fetch
#Delete remote tags.
git tag -l | xargs -n 1 git push --delete origin
#Delete local tasg.
git tag -l | xargs git tag -d