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
package lorem_grpc | |
import ( | |
"context" | |
"github.com/ru-rocker/gokit-playground/lorem-grpc/pb" | |
) | |
//Encode and Decode Lorem Request | |
func EncodeGRPCLoremRequest(_ context.Context, r interface{}) (interface{}, error) { | |
req := r.(LoremRequest) |
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
package lorem_grpc | |
import ( | |
"github.com/go-kit/kit/endpoint" | |
"context" | |
"errors" | |
) | |
//request |
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
package lorem_grpc | |
import ( | |
gl "github.com/drhodes/golorem" | |
"strings" | |
"errors" | |
"context" | |
) | |
var ( |
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
syntax = "proto3"; | |
package pb; | |
service Lorem { | |
rpc Lorem(LoremRequest) returns (LoremResponse) {} | |
} | |
message LoremRequest { | |
string requestType = 1; | |
int32 min = 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
public class CyclicRotation { | |
public int[] solution(int[] A, int K) { | |
int [] result = new int[A.length]; | |
int idx = K % A.length; | |
for(int i = 0 ; i < idx; i++){ | |
result[i] = A[A.length - idx + i]; | |
} | |
for(int j = idx; j < A.length; j++){ |
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
@Configuration | |
@EnableSwagger2 | |
public class SwaggerConfig { | |
@Bean | |
public Docket api() { | |
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any()) | |
.paths(PathSelectors.regex("/api/.*")).build().apiInfo(apiInfo()); | |
} |
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
cd $GOPATH | |
GOOS=windows GOARCH=386 go build -o runner.exe ru-rocker.com/runner/ | |
# rename file using git | |
git mv --force Foo.js foo.js |
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
Supplier<Stream<Integer>> supplier = () -> Stream.of(1, 2, 3, 4); | |
boolean anyMatch = supplier.get().anyMatch(s -> s > 0); | |
System.out.println(anyMatch);// true | |
boolean noneMatch = supplier.get().noneMatch(s -> s > 0); | |
System.out.println(noneMatch);// false |
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
Stream<Integer> stream = Stream.of(1, 2, 3, 4); | |
boolean anyMatch = stream.anyMatch(s -> s > 0); | |
System.out.println(anyMatch); | |
// true | |
boolean noneMatch = stream.noneMatch(s -> s > 0); | |
System.out.println(noneMatch); | |
// java.lang.IllegalStateException: stream has already been operated upon or closed |
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
String carModels = cars.parallelStream() | |
.map(c1 -> c1.getModel()) | |
.distinct() | |
.reduce("Renault", | |
(s1, s2) -> { | |
System.out.printf("s1: %s and s2: %s \n", s1, s2); | |
return s1 + "|" + s2; | |
}, | |
(com1, com2) -> { | |
System.out.printf("com1: %s and com2: %s \n", com1, com2); |