Skip to content

Instantly share code, notes, and snippets.

@ken5scal
ken5scal / decodeAAGUID.py
Created April 17, 2024 10:50
decode b64 encoded aaguid in authData. credentialData
import base64
import sys
def decode_and_convert_to_hex(encoded_str):
# Decode from Base64 to bytes
decoded_bytes = base64.b64decode(encoded_str)
# Convert bytes to hexadecimal
hex_string = decoded_bytes.hex()
@ken5scal
ken5scal / debug.log
Created August 16, 2018 14:46
terraform-guardduty-member-debug
2018/08/16 23:39:34 [INFO] Terraform version: 0.11.8 7a5c1d221ac209bbac66947c369815cd9ca70ed5
2018/08/16 23:39:34 [INFO] Go runtime version: go1.10.1
2018/08/16 23:39:34 [INFO] CLI args: []string{"/usr/local/bin/terraform", "apply"}
2018/08/16 23:39:34 [DEBUG] Attempting to open CLI config file: /Users/Kengo/.terraformrc
2018/08/16 23:39:34 [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2018/08/16 23:39:34 [INFO] CLI command args: []string{"apply"}
2018/08/16 23:39:34 [INFO] command: empty terraform config, returning nil
2018/08/16 23:39:34 [DEBUG] command: no data state file found for backend config
2018/08/16 23:39:34 [DEBUG] New state was assigned lineage "72c72196-5c35-d089-be74-f04f4162082e"
2018/08/16 23:39:34 [INFO] command: backend initialized: <nil>
@ken5scal
ken5scal / ECS DEPLOYMENT
Created December 31, 2016 04:30
ECS deploy shell script originally from https://github.com/circleci/circle-ecs/issues/1
#!/usr/bin/env bash
###
# Updates a pre-configured Amazon EC2 Container Service (ECS) cluster.
#
# Build a docker image in CWD, tag it and push it to hub.docker.com.
# Then Update an ECS services to run that newly available images.
#
# This script receives as a input a filename (Relative to this directory).
#
# That file must set the following Environment variables .
@ken5scal
ken5scal / file0.txt
Created December 10, 2016 09:34
GoでAESアルゴリズム(CBCモード)+PKCS7パディングを使った実装をする ref: http://qiita.com/ken5scal/items/538febf69f9ac98ab292
func PadByPkcs7(data []byte) []byte {
padSize := aes.BlockSize
if len(data) % aes.BlockSize != 0 {
padSize = aes.BlockSize - (len(data)) % aes.BlockSize
}
pad := bytes.Repeat([]byte{byte(padSize)}, padSize)
return append(data, pad...) // Dots represent it unpack Slice(pad) into individual bytes
}
@ken5scal
ken5scal / file0.txt
Last active October 13, 2018 01:56
GoでAESアルゴリズム(CBCモード)を使った実装をする ref: https://qiita.com/ken5scal/items/22efdace02b199f7007f
func EncryptByCBCMode(key []byte, plainText string) ([]byte, error) {
if len(plainText) % aes.BlockSize != 0 {
panic("Plain text must be multiple of 128bit")
}
block, err := aes.NewCipher(key); if err != nil {
return nil, err
}
cipherText := make([]byte, aes.BlockSize + len(plainText)) // 初期化ベクトルを保存するためにaes.BlockSizeを加えている
@ken5scal
ken5scal / gke_deploy.sh
Created November 23, 2016 17:27
GKE Registryアップロードのshell script
#!/bin/bash
sudo /opt/google-cloud-sdk/bin/gcloud docker push asia.gcr.io/${PROJECT_NAME}/${CONTAINER_NAME}:latest
if [[ "$CIRCLE_TAG" =~ v[0-9]+(\.[0-9]+)* ]]; then
docker tag asia.gcr.io/${PROJECT_NAME}/${CONTAINER_NAME}:$CIRCLE_SHA1 asia.gcr.io/${PROJECT_NAME}/${CONTAINER_NAME}:${CIRCLE_TAG}
sudo /opt/google-cloud-sdk/bin/gcloud docker push asia.gcr.io/${PROJECT_NAME}/${CONTAINER_NAME}:$CIRCLE_TAG
fi
package main
import (
"archive/zip"
"fmt"
"io"
"log"
"os"
"path/filepath"
)
@ken5scal
ken5scal / file0.txt
Last active February 21, 2016 18:23
明日、敗訴しないためのAndroidセキュアコーディング・フォローアップ ref: http://qiita.com/kengoscal/items/3587bcc5d652c9b86050
root@vbox86p:/data/misc/keystore/user_0 # ls -l
-rw------- keystore keystore 788 2016-02-21 13:15 10091_USRCERT_hogehoge
-rw------- keystore keystore 1252 2016-02-21 13:15 10091_USRPKEY_hogehoge <-------秘密鍵
@ken5scal
ken5scal / octave.m
Last active December 7, 2015 03:50
[初心者向け]機械学習におけるベクトル化 入門 ref: http://qiita.com/kengoscal/items/f1c949a089f3ca233af5
h = activate_function(z)
grad = 1 / m * (X'*(h-y))
@ken5scal
ken5scal / oneliner
Last active August 29, 2015 14:17
ターミナル上から一発でgenymotionを起動するワンライナー ref: http://qiita.com/ken5scal/items/beeab5ef1e89d90ff5c9
VBoxManage list vms | grep -i 'APIのバージョンやデバイス名' | head -1 | perl -ple 's/^.*\{(.*)\}/$1/g;' | xargs /Applications/Genymotion.app/Contents/MacOS/player --vm-name &