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
#!/usr/bin/env python | |
"""Simple HTTP Server With Upload. | |
This module builds on BaseHTTPServer by implementing the standard GET | |
and HEAD requests in a fairly straightforward manner. | |
""" |
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
type ByteSize float64 | |
const ( | |
_ = iota // ignore first value by assigning to blank identifier | |
KB ByteSize = 1 << (10 * iota) | |
MB | |
GB | |
TB | |
PB | |
EB |
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" | |
"math/rand" | |
"sort" | |
) | |
// slice内に指定の値があるかをチェックして | |
// 要素番号を返す関数 |
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
function kurl() { | |
# URLをパース | |
read proto server path <<<$(echo ${1//// }) | |
DOC=/${path// //} | |
HOST=${server//:*} | |
PORT=${server//*:} | |
[[ x"${HOST}" == x"${PORT}" ]] && PORT=80 | |
# /dev/tcp/~をfd3で開く | |
exec 3<>/dev/tcp/${HOST}/$PORT |
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 CarDI struct { | |
carInterface | |
} |
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 Car struct { | |
Suzuki | |
Shell | |
} |
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
// 1. A JSON file whose path is specified by the | |
// GOOGLE_APPLICATION_CREDENTIALS environment variable. | |
// For workload identity federation, refer to | |
// https://cloud.google.com/iam/docs/how-to#using-workload-identity-federation on | |
// how to generate the JSON configuration file for on-prem/non-Google cloud | |
// platforms. | |
// 2. A JSON file in a location known to the gcloud command-line tool. | |
// On Windows, this is %APPDATA%/gcloud/application_default_credentials.json. | |
// On other systems, $HOME/.config/gcloud/application_default_credentials.json. | |
// 3. On Google App Engine standard first generation runtimes (<= Go 1.9) it uses |
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 (cs computeSource) Token() (*oauth2.Token, error) { | |
if !metadata.OnGCE() { | |
return nil, errors.New("oauth2/google: can't get a token from the metadata service; not running on GCE") | |
} | |
acct := cs.account | |
if acct == "" { | |
acct = "default" | |
} | |
tokenURI := "instance/service-accounts/" + acct + "/token" | |
if len(cs.scopes) > 0 { |
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
# Google SA(gke-workload) の作成 | |
$ gcloud iam service-accounts create gke-workload --project=PROJECT_ID | |
# Google SA(gke-workload) に roles/editor 権限を付与 | |
$ gcloud projects add-iam-policy-binding PROJECT_ID \ | |
--member "serviceAccount:gke-workload@PROJECT_ID.iam.gserviceaccount.com" \ | |
--role "roles/editor" | |
# Google SA(PROJECT_ID.svc.id.goog[default/gke-workload]) が | |
# gke-workload@PROJECT_ID.iam.gserviceaccount.com の権限を借用する権限を付与 |
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
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: pod-without-sa | |
namespace: default | |
spec: | |
containers: | |
- image: gcr.io/google.com/cloudsdktool/cloud-sdk:slim | |
name: pod-without-sa | |
stdin: true |
OlderNewer