Skip to content

Instantly share code, notes, and snippets.

View steven-terrana's full-sized avatar
🚀

Steven Terrana steven-terrana

🚀
View GitHub Profile
@steven-terrana
steven-terrana / aoc_2023_day2_p2.js
Created December 3, 2023 03:45
an awful "one-liner" solution
console.log(
require('fs').readFileSync('input.txt', 'utf-8').split('\n').map( game => Object.values(Array.from(game.matchAll(new RegExp(/(?<red>\d+(?=\sred))|(?<green>\d+(?=\sgreen))|(?<blue>\d+(?=\sblue))/g))).reduce( (m, n) => {
return {
red: n.groups.red ? Math.max(m.red, Number(n.groups.red)) : m.red,
blue: n.groups.blue ? Math.max(m.blue, Number(n.groups.blue)) : m.blue,
green: n.groups.green ? Math.max(m.green, Number(n.groups.green)) : m.green
}
}, { red: 0, green: 0, blue: 0 })).reduce( (p, v) => p *= v, 1 )).reduce( (s, v) => s += v, 0)
)
@steven-terrana
steven-terrana / main.py
Created November 14, 2022 19:22
lookup zip codes from addresses
# import module
from geopy.geocoders import Nominatim
import csv
import re
# initialize Nominatim API
geolocator = Nominatim(user_agent="geoapiExercises")
filename = 'data.csv'
@steven-terrana
steven-terrana / rancher-login.sh
Created October 4, 2022 19:20
grab all available kubeconfigs from the rancher management console and consolidate
#!/bin/bash
# this script queries the rancher management console defined via
# auth.env to fetch all of the currently available kubeconfig files
#
# those kubeconfig files are then consolidated into a single kubeconfig
# in the default location
#
# after this script is run - you can use kctx to easily switch between
# available clusters
unclassified:
templateGlobalConfig:
tier:
configurationProvider: "null"
librarySources:
- libraryProvider:
plugin: "myCustomName"
/**
This step defines three agent drivers to be used: [ "docker", "kubernetes", "labels" ]
you set the default agent driver to use via:
libraries{
sdp{
agents{
driver = "kubernetes"
}
}

I’m not sure if the video you saw online was this one, but at the CDF Online Meetup I gave a no-slides all live-demo presentation introducing JTE that gets into this a bit.

The page of docs you’d be looking for is Parameterizing Libraries.

Basically, the library configuration from the pipeline configuration is made available to steps via a config variable.

pipeline_config.groovy

libraries{
 maven{
import example.GitServerProvider
ExtensionPoint.lookup(GitServerProvider).each{ s ->
def provider = s.newInstance()
provider.doThingOne()
provider.doThingTwo()
}
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: jenkins-agent
name: jenkins-agent
namespace: demo
spec:
replicas: 2
selector:
@steven-terrana
steven-terrana / application.yaml
Created September 30, 2020 17:06
use outputs from co-created resources with kubernetes-alpha provider
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config-${int}
namespace: default
data:
something: "value"
variable "field_A" {
type = string
default = "default value A"
}
output "field_A" {
value = var.field_A
}
variable "field_B" {