This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHELL := /bin/bash | |
KUBECONTEXT ?= m-ci-a-ea1-us | |
KUBECONFIG ?= "${HOME}/.kube/config" | |
.PHONY: e2e | |
e2e: | |
@if [ -f go.mod ]; then \ | |
echo "Running Go tests..."; \ | |
go mod tidy; \ | |
KUBECONFIG=$(KUBECONFIG) KUBECONTEXT=$(KUBECONTEXT) go test -test.v -race -tags=e2e ./...; \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo 'FROM alpine:3.12\nENTRYPOINT ["echo", "this is version 1"]' > Dockerfile | |
docker build -t $DOCKER_USER/tag_test . | |
docker run $DOCKER_USER/tag_test # 'this is version 1' | |
docker tag $DOCKER_USER/tag_test $DOCKER_USER/tag_test:1 | |
docker push $DOCKER_USER/tag_test | |
echo 'FROM alpine:3.12\nENTRYPOINT ["echo", "this is version 2"]' > Dockerfile | |
docker build -t $DOCKER_USER/tag_test:2 . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:latest AS build | |
WORKDIR /src | |
COPY go.sum go.mod ./ | |
RUN go mod download | |
COPY . . | |
RUN CGO_ENABLED=0 go build -o /bin/app . | |
FROM alpine | |
COPY --from=build /bin/app /bin/app | |
ENTRYPOINT ["/bin/app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:latest | |
WORKDIR /src | |
COPY go.sum go.mod ./ | |
RUN go mod download | |
COPY . . | |
RUN CGO_ENABLED=0 go build -o /bin/app . | |
ENTRYPOINT ["/bin/app"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Definition for singly-linked list. | |
* type ListNode struct { | |
* Val int | |
* Next *ListNode | |
* } | |
*/ | |
func swapPairs(head *ListNode) *ListNode { | |
// input: linked list | |
// output: linked list but every two nodes swapped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c *BufferedChannel) Recv() (interface{}, bool) { | |
c.lock.Lock() | |
defer c.lock.Unlock() | |
if c.buf.IsEmpty() && c.closed { | |
return nil, false | |
} | |
if !c.buf.IsEmpty() { | |
return c.buf.Dequeue(), true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (c *BufferedChannel) Send(val interface{}) { | |
if c.closed { | |
panic("channel closed") | |
} | |
c.lock.Lock() | |
defer c.lock.Unlock() | |
if !c.buf.IsFull() { | |
c.buf.Enqueue(val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ( | |
// ErrBufferFull occurs when the buffer is full | |
ErrBufferFull = errors.New("buffer full") | |
) | |
type buffer struct { | |
q *list.List | |
maxLen int | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def remove_tail(self): | |
# if the list is already empty, bail out | |
if self.capacity == 0: | |
return None | |
removed = self.isolate(self.root.prev) | |
self.capacity -= 1 | |
return removed | |
@staticmethod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def move_front(self, node): | |
# guard against empty nodes | |
if node is None: | |
return None | |
# Step 1: remove the node from its current position | |
node.next.prev = node.prev | |
node.prev.next = node.next | |
# Step 2: change the node so it points to the root and the old head node |
NewerOlder