Skip to content

Instantly share code, notes, and snippets.

View wubin1989's full-sized avatar

武斌 wubin1989

View GitHub Profile
@wubin1989
wubin1989 / Dockerfile
Created July 19, 2025 15:06 — forked from feltnerm/Dockerfile
Docker + MySQL + `lower_case_table_names=1`
FROM mysql
ADD my.cnf /etc/mysql/my.cnf
CMD ["mysqld", "--datadir=/var/lib/mysql", "--user=mysql"]
@wubin1989
wubin1989 / sast_article.md
Created December 24, 2024 16:49 — forked from sttor/sast_article.md
DevSecOps - Top Four OpenSource SAST tools for your CI/CD pipeline

DevSecOps - Top Four OpenSource SAST tools for your CI/CD pipeline

DevSecOps stands for Development, Security and Operations. DevSecOps involves introducing security practices and integrating tools earlier in the software development life cycle (SDLC), rather than treating security as a separate, post-development activity.

Static Application Security Testing (SAST) is one of the key security practices that can be integrated into DevSecOps. It is a type of security testing that analyzes the source code of an application to identify potential security vulnerabilities before the code is deployed. SAST tools scan the source code line by line, looking for security weaknesses such as buffer overflow, SQL injection, cross-site scripting (XSS), and other vulnerabilities that could be exploited by attackers. SAST can be done for a variety of programming languages, including C/C++, Java, Python, Ruby, and others. It can be integrated into a Continuous Integration/Continuous Deployment (CI/CD) pipeline, allowing de

@wubin1989
wubin1989 / unixhttpc.go
Created November 7, 2024 14:29 — forked from teknoraver/unixhttpc.go
HTTP over Unix domain sockets in golang
package main
import (
"context"
"flag"
"fmt"
"io"
"net"
"net/http"
"os"
@wubin1989
wubin1989 / gist:673f4f6b4456b9841ec44f5cd9158c46
Created June 30, 2023 15:00 — forked from jedp/gist:3166329
Hash to small integer
// Hash 'string' to a small number (digits default: 6)
function hash(string, digits) {
digits = digits || 6;
var m = Math.pow(10, digits+1) - 1;
var phi = Math.pow(10, digits) / 2 - 1;
var n = 0;
for (var i = 0; i < string.length; i++) {
n = (n + phi * string.charCodeAt(i)) % m;
}
return n.toString();
@wubin1989
wubin1989 / errgroup_withcontext.go
Created June 3, 2023 04:31 — forked from dragonsinth/errgroup_withcontext.go
Using errgroup.WithContext() in Golang server handlers
package main
import (
"context"
"encoding/json"
"fmt"
"io"
"log"
"sync/atomic"
"time"
@wubin1989
wubin1989 / html_entities.go
Created May 5, 2023 11:42 — forked from brandonrachal/html_entities.go
A Go Lang Program to Convert Special Symbols to HTML Entities
package main
import (
"fmt"
"bufio"
"os"
"strconv"
)
func ReadLinesFromFile(file_path string) ([]string, error) {

Two approaches to handle error responses from Spring WebClient calls globally:

  • Exceptions with webclients are all wrapped in WebClientResponseException class. So we can handle that using Spring's ExceptionHandler annotation.

  • Using ExchangeFilterFunction while constructing the webclient bean.

@wubin1989
wubin1989 / prometheus.yml
Created January 3, 2023 08:27 — forked from weibeld/prometheus.yml
Example Prometheus configuration (scrape config)
global:
scrape_interval: 10s
scrape_configs:
- job_name: node
static_configs:
- targets:
- localhost:9100
- job_name: python-app
static_configs:
- targets:
@wubin1989
wubin1989 / latency.txt
Created November 28, 2022 02:46 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
func (receiver *GoStatsImpl) LargestRemainderRpc(ctx context.Context, request *pb.PercentageReqVo) (*pb.LargestRemainderRpcResponse, error) {
var payload vo.PercentageReqVo
copier.DeepCopy(request, &payload)
data, err := receiver.LargestRemainder(ctx, payload)
if err != nil {
return nil, err
}
var ret pb.LargestRemainderRpcResponse
err = copier.DeepCopy(data, &ret.Data)
if err != nil {