Skip to content

Instantly share code, notes, and snippets.

View dishbreak's full-sized avatar

Vishal Kotcherlakota dishbreak

View GitHub Profile
#!/usr/bin/env python3
"""
Usage:
./server_control show -e ENVIRONMENT -a APPLICATION
./server_control terminate -e ENVIRONMENT -a APPLICATION
./server_control launch -e ENVIRONMENT -a APPLICATION
Options:
-e ENVIRONMENT Environment the server is in. Supported values are staging, production.
@dishbreak
dishbreak / parallel.sh
Created March 26, 2019 21:34
Executing Multiple Subprocesses in Parallel
#!/usr/bin/env bash
# kill all subprocesses when the user presses CTRL + C
trap "kill 0" SIGINT
# exit on first failed command (good practice)
set -e
echo "Starting"
@dishbreak
dishbreak / test.py
Created May 12, 2019 17:34
Assert a Partial Match on a MagicMock Object
import os
import mock
class AnyStringEndingWith(object):
def __init__(self, suffix):
self.suffix = suffix
def __repr__(self):
return "<a string ending with '%s'>" % self.suffix
@dishbreak
dishbreak / rpn.go
Created June 7, 2019 00:37
Stack and Reverse Polish Notation Calculator
package rpn
import (
"stack"
"strconv"
"strings"
)
var operators = map[string]func(int, int) int{
"+": func(left int, right int) int { return left + right },
@dishbreak
dishbreak / getitem_getattr.py
Last active August 8, 2019 18:49
Proof of concept for __getitem__ / __getattr__
class MyCoolClass(object):
def __init__(self, name):
self.name = name
foo = MyCoolClass("jordan")
print(foo.name)
@dishbreak
dishbreak / bootstrap.sh
Last active December 1, 2021 23:47
Advent of Code Bootstrap Script
#!/bin/bash
YEAR=${1:?need year as argument}
cat <<EOF >go.mod
go 1.17
module github.com/dishbreak/aoc$YEAR
EOF
go get -u github.com/dishbreak/aoc2020
@dishbreak
dishbreak / ecs_iterator.go
Last active April 1, 2022 23:01
Dealing with AWS API pagination
package ecsiterator
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ecs"
)
func GetContainerInstanceArnsForEcsCluster(e *ecs.Client, ecsClusterName string) ([]string) {
@dishbreak
dishbreak / chunking.go
Created April 2, 2022 06:09
Chunking a slice for an AWS API Call
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/service/ec2"
ec2types "github.com/aws/aws-sdk-go-v2/service/ec2/types"
)
func DescribeAllInstances(instanceIDs []string, ec2Client *ec2.Client) ([]ec2types.Instance, error) {
@dishbreak
dishbreak / main.go
Created May 13, 2023 07:45
Using a map of slices without initialization
package main
import "fmt"
type person struct {
name string
age int
}
func main() {
@dishbreak
dishbreak / Jenkins-delete-lockable-resources
Created July 10, 2023 18:53 — forked from odavid/Jenkins-delete-lockable-resources
A short script to delete free locks from the lockable resources plugin
def manager = org.jenkins.plugins.lockableresources.LockableResourcesManager.get()
def resources = manager.getResources().findAll{
!it.locked
}
resources.each{
manager.getResources().remove(it)
}
manager.save()