Skip to content

Instantly share code, notes, and snippets.

@smiley-yoyo
smiley-yoyo / .drone.yml
Created October 11, 2025 09:47
加快drone ci中docker构建速度
---
kind: pipeline
type: kubernetes
name: some-pipeline
steps:
- name: build_cache
image: plugins/docker
settings:
registry: some-registry.com
@smiley-yoyo
smiley-yoyo / delete-from-v2-docker-registry.md
Created September 3, 2025 03:46 — forked from jaytaylor/delete-from-v2-docker-registry.md
One liner for deleting images from a v2 docker registry

One liner for deleting images from a v2 docker registry

Just plug in your own values for registry and repo/image name.

registry='localhost:5000'
name='my-image'
curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$(
    curl -sSL -I \
        -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \
@smiley-yoyo
smiley-yoyo / get-argocd-default-password.md
Created July 24, 2025 02:51 — forked from iambryancs/get-argocd-default-password.md
Get ArgoCD default admin password

Get ArgoCD default admin password

To get ArgoCD default admin password after installation, run:

kubectl -n argocd get secret argocd-initial-admin-secret \
          -o jsonpath="{.data.password}" | base64 -d; echo

The default admin user is admin.

@smiley-yoyo
smiley-yoyo / text_vs_binary.go
Created April 16, 2025 12:25
Considering the definition of a binary file as "a computer file that is not a text file", they can differentiated by searching for the text/plain MIME in their MIME hierarchy.
package main
import (
"fmt"
"github.com/gabriel-vasile/mimetype"
)
func main() {
testBytes := []byte("This random text has a MIME type of text/plain; charset=utf-8.")
@smiley-yoyo
smiley-yoyo / join_test.go
Created December 20, 2024 07:25 — forked from dtjm/join_test.go
Benchmarking various ways of concatenating strings in Go
package join
import (
"fmt"
"strings"
"testing"
)
var (
testData = []string{"a", "b", "c", "d", "e"}
@smiley-yoyo
smiley-yoyo / addr_in_network.py
Last active October 23, 2024 07:19
python calc ip addr in network
import socket, struct
from ipaddress import ip_address, ip_network
# 错误代码,由于网络字节序为大字节序,而此代码试图使用小字节序处理掩码,因此当掩码不是刚好8的倍数时就会判断错误
def addr_in_network_wrong(ip, net_n_bits):
ipaddr = struct.unpack('<L', socket.inet_aton(ip))[0]
net, bits = net_n_bits.split('/')
netaddr = struct.unpack('<L', socket.inet_aton(net))[0]
netmask = ((1L << int(bits)) - 1)
return ipaddr & netmask == netaddr & netmask
@smiley-yoyo
smiley-yoyo / py-spy-record-top.sh
Created August 1, 2024 04:39
using py-spy record top cpu usage python program
#!/bin/bash
output=$1
if [ -z "$output" ]; then
output="profile.svg"
fi
# assume that the top usage program is python program, or you can customize the top command
# using head/tail to get the top 1 line (the first 8 are headers)
@smiley-yoyo
smiley-yoyo / parse_query.go
Last active July 3, 2024 06:17
parse query to map[string]any with gin
import (
"github.com/gin-gonic/gin"
)
type QueryMap map[string]any
func ParseQuery(c *gin.Context) (QueryMap, error) {
query := make(QueryMap)
if c.Request.Method == "GET" {
for k, v := range c.Request.URL.Query() {
@smiley-yoyo
smiley-yoyo / safe_time_rotating_file_handler.py
Last active June 17, 2024 11:32 — forked from SerhoLiu/safe_rotating_file_handler.py
python multiprocessing safe time rotating file handler
import logging
import os
import sys
import time
from logging.handlers import RotatingFileHandler, TimedRotatingFileHandler
from NamedAtomicLock import NamedAtomicLock
class MultiProcessLock(NamedAtomicLock):
@smiley-yoyo
smiley-yoyo / generics_aware_goimports.sh
Created April 8, 2024 02:13
How to build generics-aware goimports as of 2021/12/07
# In this script I'll use gotip, but there might be other ways
go install golang.org/dl/gotip@latest
# golang/go HEAD will be built
gotip download
# make sure gotip is available
gotip version
git clone https://github.com/golang/tools