This file contains hidden or 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
### STAGE 1: install cargo chef | |
FROM rust AS chef | |
RUN cargo install cargo-chef | |
WORKDIR /app | |
### STAGE 2: create cargo chef recipe.json | |
FROM chef AS planner | |
COPY . . | |
RUN cargo chef prepare --recipe-path recipe.json |
This file contains hidden or 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
// go version go1.21.1 darwin/amd64 | |
// $ go build -gcflags="-m -m" | |
package main | |
func main() { | |
// p escapes to heap | |
// because Func has generic parameter with type constraint containing method(s) | |
// gcshape of pointer argument to type parameter is not monomorphized, hence need to create vtable to contains methods. |
This file contains hidden or 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
// suggested solution to question on https://www.reddit.com/r/golang/comments/16g625t/cannot_compile_generic_function_that_takes_either/ | |
package main | |
import ( | |
"fmt" | |
) | |
type Iterator[T any] interface { | |
// Length return length of data on each iteration. Each iteration will reduce the length by 1. |
This file contains hidden or 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
// to run: rustc -C opt-level=3 main.rs && ./main | |
trait YF<T, U> { | |
fn apply(&self, yf: &dyn YF<T, U>, u: T) -> U; | |
} | |
impl<T, U, F> YF<T, U> for F | |
where | |
F: Fn(&dyn YF<T, U>, T) -> U, | |
{ |
This file contains hidden or 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
{"lastUpload":"2021-12-13T09:57:36.372Z","extensionVersion":"v3.4.3"} |
This file contains hidden or 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
// Y = ππ.(ππ₯.π(π₯π₯))(ππ₯.π(π₯π₯)) | |
public class YCombinator { | |
public interface F<T,U> { | |
Void apply(T name,U n); | |
} | |
public interface FF<T,U> { |
This file contains hidden or 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
package main | |
// Y = ππ.(ππ₯.π(π₯π₯))(ππ₯.π(π₯π₯)) | |
import "fmt" | |
type ( | |
F func(string, int) | |
FF func(F) F |
This file contains hidden or 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 diff(a, b time.Time) (year, month, day, hour, min, sec int) { | |
if a.Location() != b.Location() { | |
b = b.In(a.Location()) | |
} | |
if a.After(b) { | |
a, b = b, a | |
} | |
y1, M1, d1 := a.Date() | |
y2, M2, d2 := b.Date() |
This file contains hidden or 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
package fakeresponse | |
import ( | |
"testing" | |
"net/http" | |
) | |
type FakeResponse struct { | |
t *testing.T | |
headers http.Header |
This file contains hidden or 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
https://github.com/stretchr/testify (TDD) | |
https://onsi.github.io/ginkgo/ (BDD) | |
https://github.com/sirupsen/logrus (logging) | |
https://github.com/juju/errors (errors handling) |
NewerOlder