Skip to content

Instantly share code, notes, and snippets.

View Bak-Jin-Hyeong's full-sized avatar

Bak, Jin Hyeong Bak-Jin-Hyeong

View GitHub Profile
@Bak-Jin-Hyeong
Bak-Jin-Hyeong / mine_and_yours.go
Created May 20, 2022 02:23
Sloppy and crude http server app that returns IP of host and IP of client
package main
import (
"context"
"encoding/json"
"flag"
"log"
"net"
"net/http"
"os"
#!/usr/bin/env pwsh
# I always put a file named "backend.tf" in the root modules.
# Also, I don't create the name "backend.tf" in the non-root module directory.
# It seems to be my own rule, but most other people seem to do the same.
Get-ChildItem 'backend.tf' -Recurse | `
Select-Object -ExpandProperty FullName | `
ForEach-Object { `
Write-Output $_; `
terraform "-chdir=$(Split-Path $_)" init -upgrade; `
#!/usr/bin/env pwsh
git branch --format "%(if:equals=*)%(HEAD)%(then)%(refname:short)`t%(upstream:short)%(end)" | `
Where-Object { $_.Length -ne 0 } | `
ForEach-Object { $s = $_.Split("`t"); @{'branch'=$s[0]; 'upstream'=$s[1] } } | `
ConvertTo-Json
@Bak-Jin-Hyeong
Bak-Jin-Hyeong / ecs-container-metadata-v3.json
Last active June 28, 2022 02:22
${ECS_CONTAINER_METADATA_URI}
{
"DockerId": "ea7886f0fd4707b60efc507efeeaa6289b03cffe68d08bb99e04e6dc49f9d325",
"Name": "hello-ecs",
"DockerName": "ecs-task-definition-name-1-hello-ecs-bc9c99e3ea95ea981500",
"Image": "947146334561.dkr.ecr.ap-northeast-2.amazonaws.com/ecs-repository-name:hello_ecs",
"ImageID": "sha256:5373156d1db82d2920edd8790c8c6bd1a0421456c3df2e5625c12e0de24ca3a7",
"Labels": {
"com.amazonaws.ecs.cluster": "arn:aws:ecs:ap-northeast-2:947146334561:cluster/cluster-name",
"com.amazonaws.ecs.container-name": "hello-ecs",
"com.amazonaws.ecs.task-arn": "arn:aws:ecs:ap-northeast-2:947146334561:task/cluster-name/228148e27bd34dbaae2409dedabcee76",
@Bak-Jin-Hyeong
Bak-Jin-Hyeong / Verify--DigitalSign.ᅟps1
Created November 26, 2019 23:59
Verify digital signatures of executables or DLLs
function Get-RegistryValue
{
param
(
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $Path,
[parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $Value
)
if (Test-Path $Path)
{
$invocation = (Get-Variable MyInvocation).Value
$invocationDir = Split-Path $invocation.MyCommand.Path
Get-ChildItem $invocationDir | ForEach-Object {
$p = (Join-Path -Path $_.FullName -ChildPath '.git')
if (Test-Path -Path $p) {
Write-Host "git --git-dir="${p}" fetch --prune --all"
git --git-dir="${p}" fetch --prune --all
}
}
@Bak-Jin-Hyeong
Bak-Jin-Hyeong / LiteralStringViewHolder.h
Last active September 26, 2019 03:36
Restrict creation of string_view to string literals only
#ifndef LITERALSTRINGVIEW__H__
#define LITERALSTRINGVIEW__H__
#include <cassert>
#include <string_view>
class LiteralStringViewHolder;
#ifndef SPLITMIX64__H__
#define SPLITMIX64__H__
#include <cstdint>
constexpr uint64_t splitmix64_stateless(uint64_t previous_state) noexcept
{
uint64_t z = previous_state + 0x9E3779B97F4A7C15ull;
z = (z ^ (z >> 30)) * 0xBF58476D1CE4E5B9ull;
z = (z ^ (z >> 27)) * 0x94D049BB133111EBull;
#include "CoarseClock.h"
#if defined(_WIN32) || defined(_WIN64)
#if defined(_M_IX86) || defined(_M_AMD64)
#include <Windows.h>
@Bak-Jin-Hyeong
Bak-Jin-Hyeong / get_first_mac_address_windows.cpp
Created May 18, 2019 12:51
Find first mac address (windows)
#include "get_first_mac_address_windows.h"
#include <vector>
#include <WinSock2.h>
#include <ws2ipdef.h>
#include <WS2tcpip.h>
#include <iphlpapi.h>