Skip to content

Instantly share code, notes, and snippets.

View VishDev12's full-sized avatar
👋
🚀

Vishnu Deva VishDev12

👋
🚀
View GitHub Profile
@VishDev12
VishDev12 / top2vec_breakdown.py
Created November 8, 2022 06:43
A linear breakdown of the main code flow of the Top2Vec model.
# Setup and train the Doc2Vec model.
self.model = Doc2Vec()
# Get the vectors and indexes from the doc2vec model.
self.word_vectors = self.model.wv.get_normed_vectors()
self.word_indexes = self.model.wv.key_to_index
self.vocab = list(self.model.wv.key_to_index.keys())
self.document_vectors = self.model.dv.get_normed_vectors()
# Use UMAP to create 5D embeddings of the document vectors.
@VishDev12
VishDev12 / general-cpu-awsnodetemplate.yaml
Created October 16, 2022 05:26
An AWSNodeTemplate to configure the general-cpu provisioner.
apiVersion: karpenter.k8s.aws/v1alpha1
kind: AWSNodeTemplate
metadata:
name: general-cpu
spec:
subnetSelector:
karpenter.sh/discovery: cluster-name
securityGroupSelector:
karpenter.sh/discovery: cluster-name
@VishDev12
VishDev12 / general-cpu-provisioner.yaml
Created October 16, 2022 05:19
A Karpenter provisioner for general purpose workloads, with focus on cost control.
# The default provisioner used by Karpenter.
apiVersion: karpenter.sh/v1alpha5
kind: Provisioner
metadata:
name: general-cpu
spec:
# Terminate nodes x seconds after
# the last pod is removed from it.
ttlSecondsAfterEmpty: 30
@VishDev12
VishDev12 / docker-script.sh
Created October 12, 2022 15:31
Uses Docker to pull an Image to the machine.
# Install the ECR Credential Helper that automatically authenticates with ECR.
sudo yum install amazon-ecr-credential-helper -y
# Configure Docker to use the credential helper.
mkdir ~/.docker/
cat > ~/.docker/config.json << EOF
{
"credsStore": "ecr-login"
}
EOF
@VishDev12
VishDev12 / nerdctl-script.sh
Last active October 16, 2022 04:51
Uses nerdctl to pull an Image to the machine.
# Install the ECR Credential Helper that automatically authenticates with ECR.
sudo yum install amazon-ecr-credential-helper -y
# Configure Docker to use the credential helper.
mkdir ~/.docker/
cat > ~/.docker/config.json << EOF
{
"credsStore": "ecr-login"
}
EOF
@VishDev12
VishDev12 / prepull.pkr.hcl
Last active October 12, 2022 07:55
A Packer script to build EKS AMIs with Container Images baked in.
packer {
required_plugins {
amazon = {
version = ">= 0.0.2"
source = "github.com/hashicorp/amazon"
}
}
}
variable "IMAGE" {
@VishDev12
VishDev12 / general-runner.yaml
Last active July 30, 2022 07:12
Captures the two components needed for a runner using ARC.
apiVersion: actions.summerwind.dev/v1alpha1
kind: RunnerDeployment
metadata:
name: general-runner
namespace: actions-runner-system
spec:
template:
spec:
metadata:
labels:
@VishDev12
VishDev12 / gh-actions-costs.csv
Last active July 29, 2022 18:36
Compares the compute costs of Github Actions with AWS.
Provider Type Cost ($/hr) Compute
Github Actions NA 0.48 2 CPUs & 7 GB
AWS On Demand 0.101 2 CPUs & 8 GB (m5.large)
AWS Spot (cheap compute) 0.0202 2 CPUs & 8 GB (m5.large)
{0: 'tench, Tinca tinca',
1: 'goldfish, Carassius auratus',
2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias',
3: 'tiger shark, Galeocerdo cuvieri',
4: 'hammerhead, hammerhead shark',
5: 'electric ray, crampfish, numbfish, torpedo',
6: 'stingray',
7: 'cock',
8: 'hen',
9: 'ostrich, Struthio camelus',
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">