Skip to content

Instantly share code, notes, and snippets.

koduki koduki

Block or report user

Report or block koduki

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View cert.yaml
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: che-tls
namespace: che
spec:
secretName: che-tls
dnsNames:
- '*.che.hnakada128.com'
issuerRef:
@koduki
koduki / JsonParse.java
Last active Mar 11, 2020
JSON文字列をList+HashMapに変換するコード。他言語に比べてちょっと冗長なのでメモ。
View JsonParse.java
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.type.TypeReference;
var json = "[{\"name\":\"nanoha\", \"age\":10}, {\"name\":\"fate\", \"age\":10}]";
var mapper = new ObjectMapper();
var data = Arrays.asList(mapper.readValue(json, HashMap[].class));
System.out.println(data);
View gcp_memo.md

GCEでデフォルトのサービスアカウント名を取得する

$ curl "http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email" -H "Metadata-Flavor: Google"
gsu-xxx@xxxxx.iam.gserviceaccount.com

berglasによる暗号化

TLS_KEY=berglas://${BUCKET_ID}/tls-key?destination=tempfile berglas exec irb

@koduki
koduki / load_bq.sh
Last active Dec 9, 2019
This script to import from GCS to BigQuery
View load_bq.sh
#!/bin/bash
JFR_NAME=$1
JFR_JSON_PATH="gs://jfr-storage_json/$(echo ${JFR_NAME}|sed 's/.jfr$//g')"
bq load --autodetect --source_format=NEWLINE_DELIMITED_JSON jfr_logs.jdk_CPULoad ${JFR_JSON_PATH}/CPULoad.json
bq load --autodetect --source_format=NEWLINE_DELIMITED_JSON jfr_logs.jdk_ExecutionSample ${JFR_JSON_PATH}/ExecutionSample.json
bq load --autodetect --source_format=NEWLINE_DELIMITED_JSON jfr_logs.jdk_GCHeapSummary ${JFR_JSON_PATH}/GCHeapSummary.json
bq load --autodetect --source_format=NEWLINE_DELIMITED_JSON jfr_logs.jdk_GCPhaseParallel ${JFR_JSON_PATH}/GCPhaseParallel.json
bq load --autodetect --source_format=NEWLINE_DELIMITED_JSON jfr_logs.HttpRequestEvent ${JFR_JSON_PATH}/HttpRequestEvent.json
View transfer.sh
REPO=/var/log/myapp/jfr_logs
WORKDIR=/tmp
CURRENT_REPO="$REPO/"$(ls -1 $REPO|sort|head -1)
ls -l $CURRENT_REPO|awk '/jfr/{print $9, $5}'|sort > $WORKDIR/jfr.list
diff ${WORKDIR}/jfr.list ${WORKDIR}/jfr.list.prev |grep jfr|awk '$NF > 0{print $2}' > ${WORKDIR}/jfr.diff
mv $WORKDIR/jfr.list $WORKDIR/jfr.list.prev
cat ${WORKDIR}/jfr.diff|xargs -n1 -P1 -I{} gsutil cp "${CURRENT_REPO}/"{} gs://jfr-storage/
@koduki
koduki / Metrics.java
Created Dec 6, 2019
Micro Profile Metricsの値をプログラムで取得
View Metrics.java
// https://download.eclipse.org/microprofile/microprofile-metrics-2.2/microprofile-metrics-spec-2.2.html#_application_metric_registry
@Inject
@RegistryType(type = MetricRegistry.Type.BASE)
MetricRegistry baseRegistry;
@koduki
koduki / load_generator.ex
Created Nov 16, 2019
Elixirで書いてみた簡易な負荷テストツール
View load_generator.ex
defmodule LoadGenerator do
import AssertionHelper
import LogHelper
import RestHelper
def run(users_num) do
Enum.map(1..users_num, fn(x) -> Task.async(fn -> make_user() end)end)
|> Enum.map(fn(task) -> Task.await(task, 1_000_000) end)
end
@koduki
koduki / iac.yaml
Last active Oct 31, 2019
Provisioning DSL for GCP
View iac.yaml
deployment:
- name: my-environment-deployment
properties:
region: us-central1
zone: us-central1-f
networks:
- name: "my-network"
properties:
routingConfig:
routingMode: REGIONAL
@koduki
koduki / gcp.dot
Created Oct 31, 2019
GCP architecture design with Graphviz
View gcp.dot
digraph G {
layout=dot;
labeljust=l;
color=white;
internet [
label=<<table border="0"><tr><td fixedsize="true" width="32" height="32"><img src="gcp/internet.png" /></td><td>Internet</td></tr></table>>,
shape=record, color=black, style = "filled", fillcolor=white
@koduki
koduki / xdotool.sh
Created Oct 22, 2019
ラズパイでXのマウスをコマンドから操作
View xdotool.sh
# click login
DISPLAY=:0 xdotool mousemove -- 1150 25
DISPLAY=:0 xdotool click 1
# login
## user name
DISPLAY=:0 xdotool mousemove -- 1200 320
DISPLAY=:0 xdotool click 1
DISPLAY=:0 xdotool type "User Name"
You can’t perform that action at this time.