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
| data, _ := json.Marshal(context.WithValue(context.Background(), "a", "b")) | |
| fmt.Println(string(data)) |
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 | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { | |
| s := []int{1, 2} | |
| for i := range s { | |
| fmt.Println(i) |
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
| public class Constants { | |
| /** | |
| * Contains the path to your Lambda function code. | |
| */ | |
| public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT"); | |
| /** | |
| * The environment variable is set to one of the following options, depending on the runtime of the Lambda function: | |
| * AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10 |
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 | |
| import "fmt" | |
| func main() { | |
| s := "Hello world!" | |
| fmt.Printf("%c\n", s[0]) // the character represented by the corresponding Unicode code point | |
| fmt.Printf("%q\n", s[0]) // a single-quoted character (rune) at index 0 | |
| fmt.Printf("%U\n", s[0]) // print Unicode code point at index 0 | |
| fmt.Printf("%b\n", s[0]) // print binary representation of Unicode code point at index 0 |
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
| // Example how to mock mongoose method internal method | |
| // jest | mongoose | |
| jest.fn().mockImplementationOnce(() => ({ | |
| toObject: jest.fn().mockResolvedValue({id: "2333"}), | |
| lean: jest.fn().mockResolvedValue(null), | |
| })) | |
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 is lexically scoped using blocks: | |
| // The scope of a predeclared identifier is the universe block. | |
| // The scope of an identifier denoting a constant, type, variable, or function (but not method) declared at top level (outside any function) is the package block. | |
| // The scope of the package name of an imported package is the file block of the file containing the import declaration. | |
| // The scope of an identifier denoting a method receiver, function parameter, or result variable is the function body. | |
| // The scope of a constant or variable identifier declared inside a function begins at the end of the ConstSpec or VarSpec (ShortVarDecl for short variable declarations) and ends at the end of the innermost containing block. | |
| // The scope of a type identifier declared inside a function begins at the identifier in the TypeSpec and ends at the end of the innermost containing block. | |
| // An identifier declared in a block may be redeclared in an inner block. While the identifier of the inner declaration is in scope, i |
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 | |
| import ("fmt") | |
| func main() { | |
| first := []string{"1","2","3","4","5"}; | |
| second := []*string{} | |
| for _, item := range first { | |
| second = append(second, &item) | |
| } |
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 | |
| import ( | |
| "log" | |
| "net/http" | |
| "time" | |
| ) | |
| func main() { | |
| log.Println("Starting server on localhost:9090") |
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
| // Rune vs Byte | |
| package main | |
| import "fmt" | |
| func main() { | |
| const placeOfInterest = `⌘` | |
| fmt.Printf("% x\n", placeOfInterest) | |
| //range gives Unicode codepoints and the cost of parsing the next UTF-8 sequence is a reasonable, predictable, cost. | |
| for _, v := range placeOfInterest { |
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
| { | |
| "editor.fontFamily": "Fira Code", | |
| "editor.fontLigatures": true, | |
| "editor.fontWeight": "500", | |
| "editor.suggestSelection": "first", | |
| "editor.cursorBlinking": "expand", | |
| "editor.cursorSmoothCaretAnimation": true, | |
| "terminal.integrated.rightClickBehavior": "default", | |
| "editor.fontSize": 16, | |
| "workbench.colorCustomizations": { |