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
// This example shows how Go executes deferred statements in relation to a return | |
// | |
// This will output: | |
// | |
// Setting string to My first program says: | |
// Setting string to 3. Hello | |
//Setting string to 2. world | |
// Setting string to 1. from Deferred Go | |
// In main(), deferred() returned 3. Hello | |
// but str is now 1. from Deferred Go |
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 (a *IDPConfig) AuthUnaryInterceptor(authFunc AuthFunc) grpc.UnaryServerInterceptor { | |
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { | |
meta, ok := metadata.FromIncomingContext(ctx) | |
// [...] | |
token, err := a.validateToken(ctx, rawToken) | |
if err != nil { | |
return nil, status.Errorf(codes.Unauthenticated, "invalid auth token: %v", err) | |
} |
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
## Bash - OSX | |
# Get bash-completion going | |
$ brew install bash-completion | |
$ echo "[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion" >> ~/.bash_profile | |
# Put this in ~/.bash_profile | |
source <(kubectl completion bash) | |
alias k=kubectl | |
complete -F __start_kubectl k |
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
// In a Firestore standard example, we quickly create a 'xmas tree' of nested stuff | |
// We use Promises directly: get().then(callback) and use snapshot.forEach() to iterate | |
let campaignsRef = db.collection('campaigns'); | |
let activeCampaigns = campaignsRef.where('active', '==', true).select().get() | |
.then(snapshot => { | |
snapshot.forEach(campaign => { | |
console.log(campaign.id); | |
let allTasks = campaignsRef.doc(campaign.id).collection('tasks').get().then( | |
snapshot => { | |
snapshot.forEach(task => { |