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
func fieldSet(fields ...string) map[string]bool { | |
set := make(map[string]bool, len(fields)) | |
for _, s := range fields { | |
set[s] = true | |
} | |
return set | |
} | |
func IgnoreFields(v interface{}, fields ...string) map[string]interface{} { |
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 versionlock | |
import ( | |
"errors" | |
"sync/atomic" | |
"time" | |
) | |
var ErrOldVersion = errors.New("old version") | |
var ErrUnlockFailed = errors.New("unlock failed") |
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
def median(A, B): | |
m, n = len(A), len(B) | |
if m > n: | |
A, B, m, n = B, A, n, m | |
if n == 0: | |
raise ValueError | |
imin, imax, half_len = 0, m, (m + n + 1) / 2 | |
while imin <= imax: | |
i = (imin + imax) / 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
func Handler(meta endpoint.Meta, next endpoint.Endpoint) endpoint.Endpoint { | |
profMapLock.Lock() | |
defer profMapLock.Unlock() | |
traceBytes := []byte{} | |
tracePtr := &traceBytes | |
var lock sync.Mutex | |
var buf bytes.Buffer | |
var traceBuf bytes.Buffer |
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 main | |
import "fmt" | |
type FibI interface { | |
Fib(n int) int | |
Wrap(fib FibI) FibI | |
} | |
type Fib struct { |
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
// Copyright 2013 Gary Burd | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"): you may | |
// not use this file except in compliance with the License. You may obtain | |
// a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
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
// Copyright (c) 2012-2019 Grabtaxi Holdings PTE LTD (GRAB), All Rights Reserved. NOTICE: All information contained herein | |
// is, and remains the property of GRAB. The intellectual and technical concepts contained herein are confidential, proprietary | |
// and controlled by GRAB and may be covered by patents, patents in process, and are protected by trade secret or copyright law. | |
// | |
// You are strictly forbidden to copy, download, store (in any medium), transmit, disseminate, adapt or change this material | |
// in any way unless prior written permission is obtained from GRAB. Access to the source code contained herein is hereby | |
// forbidden to anyone except current GRAB employees or contractors with binding Confidentiality and Non-disclosure agreements | |
// explicitly covering such access. | |
// | |
// The copyright notice above does not evidence any actual or intended publication or disclosure of this source code, |
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 main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
func main() { | |
s := []string{"A", "B", "C"} |
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 main | |
import ( | |
"fmt" | |
"sync" | |
"time" | |
) | |
var l = sync.Mutex{} | |
var cond = sync.NewCond(&l) |
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
func TestH(t *testing.T) { | |
say := func() { | |
fmt.Println("say") | |
} | |
rec := patchFunction(&say, func() { fmt.Println("replace") }) | |
say() | |
rec() | |
say() | |
} |
NewerOlder