Skip to content

Instantly share code, notes, and snippets.

View thiskevinwang's full-sized avatar
🐵
AFK in Squamish 6/16-6/21

Kevin Wang thiskevinwang

🐵
AFK in Squamish 6/16-6/21
View GitHub Profile
@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
@thiskevinwang
thiskevinwang / gist:4849b33642d527b7262cc4fb285792a1
Created August 15, 2022 23:07
k logs pod/waypoint-task-01gahvzed9y3jgc6wdh3y81fbm-89khk
2022-08-15T23:03:49.581Z [INFO] waypoint: waypoint version: full_string="v0.9.0-374-g8b1c06ff2 (8b1c06ff2+CHANGES)" version=v0.9.0-374-g8b1c06ff2 prerelease="" metadata="" revision=8b1c06ff2+CHANGES
2022-08-15T23:03:49.582Z [DEBUG] waypoint: home configuration directory: path=/root/.config/waypoint
2022-08-15T23:03:49.582Z [INFO] waypoint.server: attempting to source credentials and connect
2022-08-15T23:03:49.584Z [DEBUG] waypoint.serverclient: connection information: address=REDACTED:9701 tls=true tls_skip_verify=true send_auth=true has_token=true
2022-08-15T23:03:49.663Z [DEBUG] waypoint.server: connection established with sourced credentials
2022-08-15T23:03:49.665Z [INFO] waypoint: server version info: version=v0.9.0-374-g8b1c06ff2 api_min=1 api_current=1 entrypoint_min=1 entrypoint_current=1
2022-08-15T23:03:49.665Z [INFO] waypoint: negotiated api version: version=1
2022-08-15T23:03:49.665Z [INFO] waypoint.runner.agent: sourcing credentials and connecting to the Waypoint server
2022-08-15T23:03:49.