Skip to content

Instantly share code, notes, and snippets.

View dishbreak's full-sized avatar

Vishal Kotcherlakota dishbreak

View GitHub Profile
@dishbreak
dishbreak / cookietest.hs
Created April 11, 2024 22:37
Advent of Code 2015 Day 15 in Haskell
import Data.List
-- Is this good haskell? I've got no idea.
-- Saving this solution because I didn't do it in go.
combos = [[a, b, c, d] | a <- [1..100], b <- [1..100], c <- [1..100], d <- [1..100], a+b+c+d == 100]
ingredients = [[2, 0, -2, 0],[0, 5, -3, 0],[0, 0, 5, -1],[0, -1, 0, 5]]
matches = [zip ingredients combo | combo <- combos ]
mults = [ [ map (\y -> y * snd x) (fst x) | x <- match ] | match <- matches ]
@dishbreak
dishbreak / README.md
Created November 29, 2023 06:43
Avent of Code: The Space Hash

The Space Hash

In a lot of Advent of Code problems, you're asked to deal with 2-dimensional or 3-dimensional data sets. Some examples of this include:

  • Cellular Automata problems: problems where each element changes based on its neighbors
  • Image processing problems: problems where we need to compose an image from pixels
  • Pathfinding problems: problems where we need to find a path across a 2-dimensional map

Why Two-Dimensional Arrays Fall Apart

@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()
@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 / 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 / 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 / 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 / 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 / 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 / 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