Skip to content

Instantly share code, notes, and snippets.

View guitarrapc's full-sized avatar
:octocat:

Ikiru Yoshizaki guitarrapc

:octocat:
View GitHub Profile

Setup

scoop install rustup
scoop install llvm
scoop install gcc

run

@guitarrapc
guitarrapc / eks_addon_configurationvalues_coredns.json
Created April 9, 2024 07:22
EKS Addon Additional Configurations for CoreDNS. Do not place CoreDNS to Karpenter Managed Node. https://aws.amazon.com/jp/blogs/containers/amazon-eks-add-ons-advanced-configuration/
{
"affinity": {
"nodeAffinity": {
"requiredDuringSchedulingIgnoredDuringExecution": {
"nodeSelectorTerms": [
{
"matchExpressions": [
{
"key": "karpenter.sh/nodepool",
"operator": "DoesNotExist"
@guitarrapc
guitarrapc / README.md
Last active March 26, 2024 02:56
ShellScript to assume role by single command
  1. Prepare profile in ~/.aws/credentials.
  2. Change from_profile and to_profile to your profile name, then Run command.
from_profile=profile-A to_profile=profile-B sts=$(aws sts assume-role --profile "${from_profile}" --role-arn $(aws configure get "${to_profile}.role_arn") --role-session-name "${to_profile}-assume"); \
export AWS_ACCESS_KEY_ID=$(echo "${sts}" | jq -r '.Credentials.AccessKeyId'); \
export AWS_SECRET_ACCESS_KEY=$(echo "${sts}" | jq -r '.Credentials.SecretAccessKey'); \
export AWS_SESSION_TOKEN=$(echo "${sts}" | jq -r '.Credentials.SessionToken') \
export AWS_EXPIRE=$(echo "${sts}" | jq -r '.Credentials.Expiration')
@guitarrapc
guitarrapc / Get-EtwTraceProvider.ps1
Last active March 22, 2024 09:32
ETW (Event Tracing for Windows) Providers and their GUIDs for Windows 10 x64
#Requires -RunAsAdministrator
#Requires -Version 5.0
# requires Windows 10
Get-EtwTraceProvider | Select-Object SessionName, Guid | sort SessionName
# as Markdown
<#
#Requires -RunAsAdministrator
$result = Get-EtwTraceProvider | sort SessionName
$result | %{"|Name|GUID|";"|----|----|";}{"|$($_.SessionName)|$($_.Guid)|"}
#>
@guitarrapc
guitarrapc / _get_github_oidc_thumbprint.sh
Last active March 19, 2024 20:19
Get Thumbprint of GitHub OIDC, updated on 2022/01/13.
$ openssl s_client -servername token.actions.githubusercontent.com -showcerts -connect token.actions.githubusercontent.com:443 < /dev/null 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sed "0,/-END CERTIFICATE-/d" > certificate.crt
$ openssl x509 -in certificate.crt -fingerprint -noout | cut -f2 -d'=' | tr -d ':' | tr '[:upper:]' '[:lower:]'
6938fd4d98bab03faadb97b34396831e3780aea1
@guitarrapc
guitarrapc / enumerate_txt.sh
Created March 12, 2024 03:34
Enumerable files under
#!/bin/bash
set -e
extension="txt"
result=$(find . -type f -name "*.${extension}" | cut -d / -f 2 | sort -u)
if [[ -n "$result" ]]; then
while read -r item; do
echo "$PWD/$item"
done <<< "$result"
@guitarrapc
guitarrapc / curl_retry.sh
Created April 13, 2023 08:20
curl retry. docker gpg server is unstable these days.... 2023
# connect-timeout: 1s = connect timeout. if network connect is stopped frequentry, 1s will be strong option.
# max-time: 10s = must finish within this time
# retry: 5 = retry count
# retry-delay: 0 = no exponential backoff
# retry max time: 60 = retry no longer than
curl --connect-timeout 1 --max-time 10 --retry 5 --retry-delay 0 --retry-max-time 60 -fsSL https://download.docker.com/linux/ubuntu/gpg
@guitarrapc
guitarrapc / Example1.ps1
Created January 26, 2015 11:46
Rename Resource prefix
# You can specify Path and ResourceName to strictly identify.
Rename-DSCModuleResourcePrefix -Path c:\Path\To\Resource\Directory -ResourceName ResourcenameToRename -NewPrefix c -Verbose
@guitarrapc
guitarrapc / Get-DockerMemoryStatus.ps1
Last active January 25, 2024 06:21
Get docker memory status for Windows running Docker Desktop for Windows.
$reservedMemoryMB = Get-Content -Raw -Path "${env:APPDATA}/Docker/settings.json" | ConvertFrom-Json | Select-Object -ExpandProperty memoryMiB
$dockerStats = docker stats --no-stream --format "{{.MemUsage}}"
$totalMemoryKB = 0
foreach ($line in $dockerStats) {
$memoryUsage = $line.Split('/')[0].Trim()
$value = [double]($memoryUsage -replace '[^\d.]')
if ($memoryUsage -match "GiB") {
$totalMemoryKB += $value * 1024 * 1024
} elseif ($memoryUsage -match "MiB") {
@guitarrapc
guitarrapc / README.md
Created January 25, 2024 02:46
Docker Dekstop for Windows. %APPDATA%\Docker\settings.json files for Docker Engine backend with Hyper-V or WSL2

tl;dr;

%APPDATA%\Docker\settings.json file for Docker Engine backend with Hyper-V or WSL2.

Environment

Windows 11 Pro 22H2

$ wsl --version