This is the gist version of my blog post Quick Dockerfile for Python Poetry Projects.
I hope you find it useful.
// source: https://stackoverflow.com/questions/41240761/check-if-ip-address-is-in-private-network-space | |
var privateIPBlocks []*net.IPNet | |
func init() { | |
for _, cidr := range []string{ | |
"127.0.0.0/8", // IPv4 loopback | |
"10.0.0.0/8", // RFC1918 | |
"172.16.0.0/12", // RFC1918 | |
"192.168.0.0/16", // RFC1918 | |
"169.254.0.0/16", // RFC3927 link-local |
This is the gist version of my blog post Quick Dockerfile for Python Poetry Projects.
I hope you find it useful.
// pkcs7strip remove pkcs7 padding | |
func pkcs7strip(data []byte, blockSize int) ([]byte, error) { | |
length := len(data) | |
if length == 0 { | |
return nil, errors.New("pkcs7: Data is empty") | |
} | |
if length%blockSize != 0 { | |
return nil, errors.New("pkcs7: Data is not block-aligned") | |
} | |
padLen := int(data[length-1]) |
FROM golang:1-alpine as golang | |
RUN apk --no-cache add git zip tzdata ca-certificates | |
# avoid go path, use go mod | |
WORKDIR /app | |
COPY . . | |
RUN CGO_ENABLED=0 go build -ldflags "-s -w -extldflags "-static"" ./cmd/appnamehere | |
WORKDIR /usr/share/zoneinfo | |
# -0 means no compression. Needed because go's | |
# tz loader doesn't handle compressed data. | |
RUN zip -r -0 /zoneinfo.zip . |
#!/usr/bin/env bash | |
set -e | |
# dependecies | |
apt update | |
apt install -y git automake build-essential pkg-config libevent-dev libncurses5-dev byacc | |
# where our temp file locates | |
rm -rf /tmp/tmux |
{ | |
"123":"application/vnd.lotus-1-2-3", | |
"ez":"application/andrew-inset", | |
"aw":"application/applixware", | |
"atom":"application/atom+xml", | |
"atomcat":"application/atomcat+xml", | |
"atomsvc":"application/atomsvc+xml", | |
"ccxml":"application/ccxml+xml", | |
"cdmia":"application/cdmi-capability", | |
"cdmic":"application/cdmi-container", |
func openBrowser(url string) { | |
var err error | |
switch runtime.GOOS { | |
case "linux": | |
err = exec.Command("xdg-open", url).Start() | |
case "windows": | |
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() | |
case "darwin": | |
err = exec.Command("open", url).Start() |
Flink has a deadlock case and can be caused by the combination of Flink's backpressure mechanism with iterations (more likely when there is heavy feedback load).
There is a proposal to resolve this issue, but it seems to be abondoned.
The walkaround, suggested by Gábor Hermann, is to throttle messages into the iteration.
Here is my implementation.
FROM golang:buster as golang | |
RUN apt-get update && \ | |
DEBIAN_FRONTEND=noninteractive apt-get install -y \ | |
ca-certificates \ | |
tzdata \ | |
build-essential \ | |
tar \ | |
bash | |
WORKDIR /app | |
COPY . . |
func firstNUTF8AtMost(s string, n int) string { | |
i := 0 | |
for j := range s { | |
if i >= n { | |
return s[:j] | |
} | |
i++ | |
} | |
return s | |
} |