Skip to content

Instantly share code, notes, and snippets.

View lirlia's full-sized avatar

gin lirlia

View GitHub Profile
@lirlia
lirlia / SimpleHTTPServerWithUpload.py
Created February 9, 2021 02:17 — forked from UniIsland/SimpleHTTPServerWithUpload.py
Simple Python Http Server with Upload
#!/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.
"""
@lirlia
lirlia / iota.txt
Last active June 29, 2021 12:27
golang-technic
type ByteSize float64
const (
_ = iota // ignore first value by assigning to blank identifier
KB ByteSize = 1 << (10 * iota)
MB
GB
TB
PB
EB
package main
import (
"fmt"
"math/rand"
"sort"
)
// slice内に指定の値があるかをチェックして
// 要素番号を返す関数
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
package main
import (
"fmt"
)
type Car struct {
Suzuki
Shell
}
package main
import (
"fmt"
)
type CarDI struct {
carInterface
}
// 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
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 {
# 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 の権限を借用する権限を付与
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