Skip to content

Instantly share code, notes, and snippets.

View h1z3y3's full-sized avatar
👀
I'm watching on you 🤫

zhaoyang h1z3y3

👀
I'm watching on you 🤫
View GitHub Profile
function tohex(str)
return (str:gsub('.', function (c)
return string.format('%02X', string.byte(c))
end))
end
function fromhex(str)
return (str:gsub('..', function (cc)
return string.char(tonumber(cc, 16))
end))
@h1z3y3
h1z3y3 / oneOf.cue
Created January 24, 2022 16:14
cue oneOf pattern
#OneOf: { a: string } | { b: string }
#E: {
name: string
#OneOf
}
ex1: #E & {
name: "a choice"
a: "bar"
@h1z3y3
h1z3y3 / anyOf.cue
Created January 24, 2022 16:13
cue anyOf pattern
import "list"
val: this={
a?: string
b?: string
c?: string
#AnyOfABC: true & list.MinItems([for label,_ in this if list.Contains(["a", "b", "c"],label) {label}], 1)
d?: string
e?: string
package function
import "strings"
// An input schema
#Input: {
count: int
msg: string
}
import "strings"
band: {
// hidden fiels
_selfIndexAlbums: ["", "II", "III", "IV"]
_namedAblums: [
"Houses of the Holy",
"Physical Graffiti",
"Presence",
"In Through the Out Door",
req, _ := http.NewRequest("GET", "http://your_link_url", nil)
req.Header.Set("Authorization", fmt.Sprintf("Bearer xxxxxxxx"))
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, _ := client.Do(req)
# add same content to the head of every line
:%s/^/the_content
# add same content to the tail of every line
:%s/$/the_content
# combine lines in vim
server {
listen 80;
server_name .example.com
return 301 https://example.com
}
server {
listen 443 ssl;
server_name .example.com
$ luarocks install --tree=/path/you/want/to/install lua-resty-ipmatcher
FROM golang:1.17.5-alpine AS BUILDER
COPY . /go/src/app
WORKDIR /go/src/app
RUN go build -mod=mod -o app
FROM golang:1.17.5-alpine
WORKDIR /app