Skip to content

Instantly share code, notes, and snippets.

@shivam-nagar
shivam-nagar / kubeclr.bash
Last active February 20, 2024 08:53
Interactive kubectx context cleanup bash script
kubeclr() {
kubectx | while read -r cluster ; do
echo "\ndelete $cluster (y/N)?";
read -k1 -s del;
if [ $del = "y" ]; then
kubectx -d $cluster;
fi
done
}
@shivam-nagar
shivam-nagar / copy-curl.sh
Created September 1, 2023 08:01
Copy Image to new Container repository
SOURCE_NAME="us-west1-docker.pkg.dev/zerok-dev/curl"
SOURCE_TAG="7.7.0"
TARGET_NAME="us-west1-docker.pkg.dev/zerok-prod/stage/curl"
TARGET_TAG="1.0.0"
docker pull $SOURCE_NAME:$SOURCE_TAG
docker tag $SOURCE_NAME:$SOURCE_TAG $TARGET_NAME:$TARGET_TAG | docker push $TARGET_NAME:$TARGET_TAG
@shivam-nagar
shivam-nagar / upgrade.sh
Last active October 25, 2022 05:16
Script to upgrade to latest istioctl version.
#!/bin/bash
cd /tmp/
rm -rf istio*
curl -L https://istio.io/downloadIstio | sh -
cd istio*
find $HOME/.istioctl -not -name 'upgrade.sh' -delete
@shivam-nagar
shivam-nagar / 3_Ballot.sol
Created May 3, 2022 19:18
ZKU - Background Assignment [B.3 - Ballot] : limit the voting period of each Ballot contract to 5 minutes.
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title Ballot
* @dev Implements voting process along with vote delegation
*/
contract Ballot {
@shivam-nagar
shivam-nagar / HelloWorld.sol
Created May 3, 2022 19:10
ZKU - Background Assignment [B.1 - Hello World]
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.7.0 <0.9.0;
/**
* @title HelloWorld
* @dev Store & retrieve value in a variable
*/
contract HelloWorld {
@shivam-nagar
shivam-nagar / aws-ecr-delete-repositories.js
Created July 23, 2021 19:02
AWS ECR Delete Repositories Bulk
const skipRepoList = [ /* List of repos to skip deletion. */ ]
const AWS_REGION = "us-west-2"
const { ECRClient, DescribeRepositoriesCommand, DeleteRepositoryCommand } = require("@aws-sdk/client-ecr");
async function deleteRepositories(repoName) {
const awsClient = new ECRClient({ region: AWS_REGION });
const deleteCommand = new DeleteRepositoryCommand({repositoryName: repoName, force: true});
await awsClient.send(deleteCommand)
.then((DeleteRepositoryResponse) => {
@shivam-nagar
shivam-nagar / aws-ecs-deregister-task-definitions.js
Created July 23, 2021 17:50
AWS ECS Deregister Task definitions Bulk
const skipTaskDefList = [ /* List of task names to skip deletion. */ ]
const AWS_REGION = "us-west-2"
const { ECSClient, ListTaskDefinitionsCommand, DeregisterTaskDefinitionCommand } = require("@aws-sdk/client-ecs");
async function deleteTaskDef(taskDefARN) {
const awsClient = new ECSClient({ region: AWS_REGION });
const deleteCommand = new DeregisterTaskDefinitionCommand({taskDefinition: taskDefARN});
await awsClient.send(deleteCommand)
.then((deregisterTaskDefinitionResponse) => {