I hereby claim:
- I am brianfoshee on github.
- I am brianfoshee (https://keybase.io/brianfoshee) on keybase.
- I have a public key whose fingerprint is B1D6 5507 539E 26B2 D0BF 6C8E 0CF2 BD06 C38B 4EF1
To claim this, I am signing this object:
// Generate a Country's Flag Emoji given its 2 letter Country Code | |
// https://emojipedia.org/flags/ | |
function flagEmojiFromCountryCode(code) { | |
if (code.length != 2) { | |
// Must be ISO 3166-1 alpha-2 | |
throw new Error(`Country Code "${code}" must be 2 characters`); | |
} | |
var base = 0x1F1E6 // hex of unicode code point for 🇦, "Regional Indicator Symbol Letter A" | |
var a = 'a'.charCodeAt(0) // => 97. Used for calculating unicode offsets from base. |
I hereby claim:
To claim this, I am signing this object:
package main | |
import ( | |
"fmt" | |
"testing" | |
) | |
var result string | |
func BenchmarkSprintf(b *testing.B) { |
// bufPool is a pool of byte buffers meant to used when encoding JSON responses | |
// out to a client. | |
// giving this a try over: | |
// https://github.com/oxtoacart/bpool/blob/master/bufferpool.go | |
var bufPool = sync.Pool{ | |
New: func() interface{} { | |
return new(bytes.Buffer) | |
}, | |
} |
set laststatus=2 " Always show status line | |
set statusline=%f " Path to the file | |
set statusline+=%< " If status line is too long truncate here | |
set statusline+=\ %y " File type, e.g. [go] | |
set statusline+=%r " [RO] if file is read only | |
set statusline+=%m " [+] if file is modified | |
set statusline+=%= " Switch to right side | |
set statusline+=%p%% " Percentage through file in lines | |
set statusline+=\ %l,%c " Line, Column numbers |
type Payment struct { | |
ID string | |
Amount uint64 | |
Name string | |
Description string | |
Email string | |
Status PaymentStatus | |
StripeTokenID string |
// compareJSON is a lightweight alternative to | |
// https://github.com/onsi/gomega/blob/master/matchers/match_json_matcher.go | |
func compareJSON(actual []byte, expected []byte) error { | |
var aval interface{} | |
var eval interface{} | |
if err := json.Unmarshal(actual, &aval); err != nil { | |
return err | |
} | |
if err := json.Unmarshal(expected, &eval); err != nil { |
// This package is an example of using custom context handlers and middleware. | |
// It is largely based on the final option in this article: | |
// https://joeshaw.org/net-context-and-http-handler/ | |
// I have added a middleware chaining method and an associated ContextMW type. | |
// | |
// The idea is that in the case of this proposal being accepted, | |
// https://github.com/golang/go/issues/14660#issuecomment-193914014, | |
// where the context package would be in the standard library and implemented | |
// on http.Request, that these same handlers and middleware could be used after | |
// a brief refactoring to remove the custom types. |
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"sync" | |
"time" | |
) | |
func main() { |
package loop | |
import "testing" | |
func BenchmarkFor(b *testing.B) { | |
for i := 0; i < b.N; i++ { | |
lang := "de-de" | |
supported := []string{"en-us", "ja-jp", "de-de"} | |
found := false | |
for _, s := range supported { |