user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
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 ( | |
| "context" | |
| "fmt" | |
| "log" | |
| "runtime" | |
| "github.com/aws/aws-sdk-go-v2/aws" | |
| "github.com/aws/aws-sdk-go-v2/config" |
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
| on run {input, parameters} | |
| if (count of input) > 0 then | |
| tell application "iTerm" | |
| activate | |
| # Support editing of multiple files with vim tabs. | |
| set filesPathsToEdit to "" | |
| set numItems to the count of items of input | |
| repeat with x from 1 to numItems | |
| set posixPath to quoted form of POSIX path of item x of input |
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
| // lowercaseAlphaHasUniqueChars returns true if the passed string contains | |
| // all unique lowercase alphabet characters. | |
| func lowercaseAlphaHasUniqueChars(s string) bool { | |
| var mask int | |
| for i := 0; i < len(s); i++ { | |
| // left shift 1 the distance of the character from 'a' times | |
| position := 1 << (s[i] - 'a') | |
| // if the bitwise logical AND is equal to 0, | |
| // then we've not seen the character before |
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
| m := map[string]int{ | |
| "Alien Covenant": 202, | |
| "The Imitation Game": 98, | |
| "Good Will Hunting": 98, | |
| "Spaceballs": 146, | |
| } | |
| // Place each movie's title into an slice of strings | |
| var movies []string | |
| for k := range m { |
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
| m := map[string]int{ | |
| "Alien Covenant": 202, | |
| "The Imitation Game": 98, | |
| "Good Will Hunting": 98, | |
| "Spaceballs": 146, | |
| } | |
| // Create a structure to capture the association in the map | |
| type movie struct { | |
| title string |
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
| m := map[string]int{ | |
| "Alien Covenant": 202, | |
| "The Imitation Game": 98, | |
| "Good Will Hunting": 98, | |
| "Spaceballs": 146, | |
| } | |
| // Create a structure to capture the association in the map | |
| type movie struct { | |
| title string |
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
| # Targets not related to individual files | |
| .PHONY: all build test cover_func cover_html out clean vet loc run fmt test_v bench | |
| # Build constants | |
| BUILD_OUT_DIR = bin | |
| BINARY_FILE_NAME = <name of binary output file for program> | |
| MAIN_PROGRAM_FILE = main.go | |
| TEST_COVERAGE_PROFILE = coverage.out | |
| all: out fmt vet test_v loc build |
https://martinfowler.com/articles/mocksArentStubs.html#UsingEasymock
- Dummy objects are passed around but never actually used. Usually they are just used to fill parameter lists.
- Fake objects actually have working implementations, but usually take some shortcut which makes them not suitable for production (an in memory database is a good example).
- Stubs provide canned answers to calls made during the test, usually not responding at all to anything outside what's programmed in for the test.
- Spies are stubs that also record some information based on how they were called. One form of this might be an email service that records how many messages it was sent.
- Mocks are what we are talking about here: objects pre-programmed with expectations which form a specification of the calls they are expected to receive.
NewerOlder