Skip to content

Instantly share code, notes, and snippets.

@mrkagelui
mrkagelui / update-buddy-helm.sh
Last active January 13, 2022 03:35
using turbolift to update helm chart version defined in buddy.works pipeline definitions
# Turbolift recipe to update helm template versions
#
# prerequisites:
# 1. https://github.com/Skyscanner/turbolift#installation
# 2. https://github.com/mikefarah/yq#install
#
# assumptions:
# 1. you have all buddy pipeline definitions under `/.buddy` directory of each repo and they all have `.yaml` or `.yml` extension
# 2. you define the helm chart version in an action of type `HELM` which has a list of `execute_commands`, and the version is passed in like `--version $version`. In other words, there's an action that looks like:
# - action: Render k8s manifest from Helm chart
@mrkagelui
mrkagelui / upload.go
Last active May 19, 2023 19:11
stream data from DB to upload
package main
import (
"context"
"encoding/csv"
"errors"
"fmt"
"io"
"log"
"os"
@mrkagelui
mrkagelui / example1.go
Last active April 29, 2022 01:57
optimize ram with go snippet 1
// dataStore retrieves data
type dataStore interface {
getData(context.Context, filter) ([]item, error)
}
// fileStorage uploads the data to file storage
type fileStorage interface {
upload(context.Context, []byte) error
}
@mrkagelui
mrkagelui / example2.go
Created April 29, 2022 01:58
example2
// fileStorage uploads the data to file storage
type fileStorage interface {
upload(context.Context, []byte) error
}
// fileStorage uploads the data to file storage
type fileStorage interface {
upload(context.Context, io.Reader) error
}
// run is the main logic of the service
func (s service) run(ctx context.Context, f filter) error {
pr, pw := io.Pipe()
r, err := s.ds.getData(ctx, f)
if err != nil {
return fmt.Errorf("querying: %v", err)
}
go writeRowsToCSV(r, pw)
func main() {
f, err := os.Create("cpu.prof")
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
// the rest of the logic
}
func main() {
f, err := os.Create("cpu.prof")
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
// the rest of the logic
}