Skip to content

Instantly share code, notes, and snippets.

View ionling's full-sized avatar
🍃
Having fun with nature

ionling ionling

🍃
Having fun with nature
View GitHub Profile
@ionling
ionling / main.go
Last active January 18, 2024 07:00
Check PostgreSQL data differences
package main
import (
"context"
"database/sql"
"flag"
"fmt"
"log/slog"
"math/rand"
"os"
@ionling
ionling / health.go
Created November 13, 2023 06:39
Service health checkers
package health
import (
"context"
khttp "github.com/go-kratos/kratos/v2/transport/http"
)
type Health struct {
checkers []Checker
@ionling
ionling / keybase.md
Created September 27, 2022 03:48
keybase.md

Keybase proof

I hereby claim:

  • I am ionling on github.
  • I am ionling (https://keybase.io/ionling) on keybase.
  • I have a public key whose fingerprint is D71D E310 B082 F321 BCE9 5C00 9E38 C298 6D1A 3C93

To claim this, I am signing this object:

@ionling
ionling / chan.go
Created September 23, 2021 01:52
Implementing golang channel
package channel
import (
"sync"
"time"
)
type Channel struct {
lock sync.Mutex
value interface{}
@ionling
ionling / go-shorten-lines.el
Created April 29, 2021 11:43
Emacs golines wrapper
;; Require golines tool.
;; See https://github.com/segmentio/golines
(defun v-go-shorten-lines ()
"Shorten long lines in current file."
(interactive)
(save-buffer)
(shell-command
(format "golines --no-reformat-tags -m %s -w %s"
fill-column buffer-file-name)))
@ionling
ionling / request_validate.py
Created March 1, 2020 07:18
JSON type validate decorator for Django REST framework
import functools
from enum import Enum
from rest_framework.response import Response
class BadRequest(Response):
"""400 Bad Request
May be used to indicate nonspecific failure.
400 is the generic client-side error status, used when no other 4xx error
@ionling
ionling / testlink.less
Created February 15, 2020 13:11
Simple theme for TestLink
@ionling
ionling / utils.py
Created February 8, 2020 09:21
Generate random string with given prefix (Python3)
import random
import string
def random_str(prefix="", size=10) -> str:
"""Generate random string with given prefix.
Args:
prefix : Prefix of string
size : Random string's total size