Skip to content

Instantly share code, notes, and snippets.

View thiskevinwang's full-sized avatar

Kevin Wang thiskevinwang

View GitHub Profile
@thiskevinwang
thiskevinwang / ._README.md
Last active July 12, 2024 17:15
cognito_test

Description

A .ts script to output information about a Cognito user pool. This uses the V3 JS client to call describe-user-pool

This is simply one means, amongst many, to fetch user pool info.

Setup

user@~: $ mkdir cognito_test
@thiskevinwang
thiskevinwang / main_test.go
Created November 17, 2023 13:45
go-bench
// benchmarking two flavors of logging
//
// run with `go test -benchmem -bench=.`
//
// Example output:
// ----------------------------------------------------------
// goos: darwin
// goarch: arm64
// pkg: go-benchmarks
// BenchmarkLogPlain-10 3548698 332.0 ns/op 64 B/op 2 allocs/op
@thiskevinwang
thiskevinwang / boost.js
Last active October 2, 2023 21:20
Arc Boost — Click to copy GitHub PR title as richtext link to Clipboard
function copyToClip(str) {
function listener(e) {
e.clipboardData.setData("text/html", str);
e.clipboardData.setData("text/plain", str);
e.preventDefault();
}
document.addEventListener("copy", listener);
document.execCommand("copy");
document.removeEventListener("copy", listener);
};
@thiskevinwang
thiskevinwang / Prompt.md
Last active September 29, 2023 00:17
$100 Password hack challenge

Sep 28, 2023 - $100 Password hack challenge

What is this?

Here is a simulated scenario where you are a hacker and you have gained access to a passwords database. For simplicity, there are only 2 rows.

...the bounty...

I (@thiskevinwang) will venmo $100 USD to the first person who can provide the password behind either of these two rows.

@thiskevinwang
thiskevinwang / lambda-node-code-that-streams.ts
Created May 17, 2023 13:09
lambda-node-code-that-streams
import util from "util";
import stream from "stream";
const { Readable } = stream;
const pipeline = util.promisify(stream.pipeline);
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
export const handler = awslambda.streamifyResponse(
async (event, responseStream, context) => {
const s3 = new S3Client({ region: "us-east-1" });
@thiskevinwang
thiskevinwang / test.js
Last active April 11, 2023 20:04
Semver Package
// run on runkit: https://runkit.com/embed/igg9vk09v684
const semver = require('semver')
semver.clean("v1.5.0-alpha20230405") // "1.5.0-alpha20230405"
semver.prerelease('v1.5.0-alpha20230405') // ["alpha20230405"]
semver.prerelease('v1.5.0-beta.1') // ["beta", 1]
semver.prerelease('v1.5.0-rc.1') // ["rc", 1]
semver.prerelease('v1.5.0-rc1') // ["rc1"]
@thiskevinwang
thiskevinwang / delete_github_environments.sh
Created April 1, 2023 13:12
Delete GitHub environments
#!bin/sh
# This script fetches GitHub environments and delets them
# - requires the `gh` CLI
# - requires `jq`
envs=$(gh api repos/{owner}/{repo}/environments --paginate | jq -r ".environments[].name")
for env in $envs
do
[ec2-user@ip-172-31-89-170]~% sudo yum repolist
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
repo id repo name status
!amzn2-core/2/aarch64 Amazon Linux 2 core repository 20,542
amzn2extra-docker/2/aarch64 Amazon Extras repo for docker 66
amzn2extra-kernel-5.10/2/aarch64 Amazon Extras repo for kernel-5.10 213
hashicorp/aarch64 Hashicorp Stable - aarch64 274
repolist: 21,095
@thiskevinwang
thiskevinwang / waypoint-server-logs.txt
Created November 14, 2022 06:00
Waypoint UI crashing when clicking into project deployed/released via apprunner)
2022-11-14T05:56:48.787Z [INFO] waypoint.server.grpc: /hashicorp.waypoint.Waypoint/UI_GetProject request
2022-11-14T05:56:48.789Z [INFO] waypoint.server.grpc: /hashicorp.waypoint.Waypoint/UI_GetProject response: error=<nil> duration=2.324584ms
2022-11-14T05:56:48.790Z [INFO] waypoint.server.http: HTTP request: POST /grpc/hashicorp.waypoint.Waypoint/UI_GetProject: ln=[::]:9702 date=2022-11-14T05:56:48.786647255Z http.host=localhost:9702 http.method=POST http.request_path=/grpc/hashicorp.waypoint.Waypoint/UI_GetProject http.remote_addr=172.18.0.1 http.response_size=76 http.scheme="" http.scheme_forwarded=false http.tls=true http.status_code=200 http.useragent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36" http.version=HTTP/1.1
2022-11-14T05:56:50.442Z [INFO] waypoint.server.grpc: /hashicorp.waypoint.Waypoint/UI_ListReleases request
2022-11-14T05:56:50.443Z [INFO] waypoint.server.grpc: /hashicorp.waypoint.Waypoint/ListPushedArtifacts r