Skip to content

Instantly share code, notes, and snippets.

View tomarv2's full-sized avatar

Varun Tomar tomarv2

View GitHub Profile
@tomarv2
tomarv2 / settings.json
Last active February 28, 2023 16:50
Visual Studio code settings (update python.defaultInterpreterPath)
{
"python.defaultInterpreterPath": "/Users/demo/.pyenv/versions/3.8.10/envs/3.8/bin/python",
"python.pythonPath": "/usr/local/anaconda3/bin/python",
"python.terminal.activateEnvironment": true,
"terminal.integrated.inheritEnv": true,
"workbench.colorTheme": "Predawn",
"redhat.telemetry.enabled": false,
"code-runner.runInTerminal": true,
"python.linting.pylintArgs": [
"--reports",
@tomarv2
tomarv2 / gist:b9c6ec6cab9446ac71ef4f64d6cc767f
Created January 27, 2023 19:22
encrypt_decrypt_using_kms.py
import base64
import boto3
REGION_NAME = "us-east-2"
# Decrypt value using AWS KMS Key
kmsclient = boto3.client('kms', region_name=REGION_NAME)
ciphertext = "encryted_value"
@tomarv2
tomarv2 / mutliprocessing_apply_async_with_callback.py
Created January 24, 2022 20:35
mutliprocessing using pool with apply_async with callback
from multiprocessing import Pool
import os
import time
list_of_movie_names = ["john_wick_1", "john_wick_1", "john_wick_3"]
def hello_world(name):
print("IT WASN'T JUST A PUPPY")
time.sleep(1)
@tomarv2
tomarv2 / mutliprocessing_apply_async_with_return.py
Last active January 24, 2022 20:31
mutliprocessing using pool with apply_async
from multiprocessing import Pool
import os
import time
def hello_world(name):
print("IT WASN'T JUST A PUPPY")
time.sleep(1)
print('YOU WANTED ME BACK...')
return f"Hello: {name}"
@tomarv2
tomarv2 / security_scans.yml
Created March 20, 2021 17:48
Checkov Security Scan
name: Security Scans
on:
push:
branches:
- develop
- main
paths-ignore:
- 'README.md'
- 'LICENSE'
@tomarv2
tomarv2 / github-actions-workflow-runs-cleanup
Last active March 5, 2021 05:24
GitHub Action workflow runs cleanup
# NOTE: Ensure you are logged into the right github account
# https://cli.github.com/manual/gh_auth_login
OWNER=tomarv2
REPO=demo
# list all workflows
gh api -X GET /repos/$OWNER/$REPO/actions/workflows | jq '.workflows[] | .name,.id'
# get the workflow id you want to clear
@tomarv2
tomarv2 / bridgecrew-check-github-actions.yml
Created February 28, 2021 05:47
GitHub Actions for security scan of Lambda using BridgeCrew
name: Security Scans
on:
push:
branches:
- main
- develop
paths-ignore:
- 'README.md'
- 'LICENSE'
@tomarv2
tomarv2 / terratest-aws-lambda
Last active July 14, 2021 06:10
terratest aws lambda
package test
import (
"testing"
"github.com/gruntwork-io/terratest/modules/aws"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
)
@tomarv2
tomarv2 / git-cheat-sheet.txt
Last active March 14, 2021 19:02
Git cheat sheet
# -----------------------------------------------------
# Cleanup git history
# -----------------------------------------------------
# NOTE: DO NOT DELETE the .git folder it may cause problems in git repository.
# If we want to delete commits history, but keep the code, please try below:
# Check out to a temporary branch:
git checkout --orphan temp_branch
@tomarv2
tomarv2 / gcp_get_secret.py
Created February 15, 2021 02:03
GCP: Get secret from Secret Manager
# from: https://cloud.google.com/secret-manager/docs/managing-secrets
from google.cloud import secretmanager
project_id = "demo_project_id"
secret_name = "hello"
version = 1
def access_secret_version(project_id, secret_id, version_id):