Skip to content

Instantly share code, notes, and snippets.

@dmikusa
dmikusa / main.go
Created March 18, 2024 03:42
Update a buildpack.toml file. For automating changes across many buildpacks.
package main
import (
"bytes"
"fmt"
"os"
"path/filepath"
"strings"
"github.com/BurntSushi/toml"

Programming Challenges

  • Pick something and implement it
  • The topics are open-ended
  • Pairing is suggested
  • Want to try some new tech, this is a great time
  • You may use any tools that you like, including code generators and AI, but make sure you can roughly explain what your code is going at the end
  • Towards the end, we'll ask people to show off their work. A demo or quick code walk through. Nothing crazy, just a couple minutes.
  • You must decide what you implement. Consider time, what you can deliver, what you can reasonably demo, and wow factor.
@dmikusa
dmikusa / get_sbom_layer.sh
Created February 17, 2022 04:03
A script that uses `curl` to download the SBOM layer of an OCI image created with Cloud-Native buildpacks
#!/bin/bash
set -eio pipefail
IMAGE="$1"
TAG="$2"
TOKEN=$(curl -s "https://auth.docker.io/token?scope=repository:$IMAGE:pull&service=registry.docker.io" | jq -r .token)
MANIFEST=$(curl -s -L -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer $TOKEN" https://registry-1.docker.io/v2/$IMAGE/manifests/$TAG)
@dmikusa
dmikusa / DemoApplication.java
Created September 26, 2021 18:12
Example of loading security groups & security group guid
package com.example.demo;
import org.cloudfoundry.client.CloudFoundryClient;
import org.cloudfoundry.client.v2.securitygroups.ListSecurityGroupsRequest;
import org.cloudfoundry.client.v2.securitygroups.ListSecurityGroupsResponse;
import org.cloudfoundry.client.v2.securitygroups.SecurityGroupResource;
import org.cloudfoundry.reactor.ConnectionContext;
import org.cloudfoundry.reactor.DefaultConnectionContext;
import org.cloudfoundry.reactor.TokenProvider;
import org.cloudfoundry.reactor.client.ReactorCloudFoundryClient;
#!/bin/bash
set -e
# requires `jq`
function load_all_pages {
URL="$1"
DATA=""
until [ "$URL" == "null" ]; do
RESP=$(cf curl "$URL")
DATA+=$(echo "$RESP" | jq .resources)
@dmikusa
dmikusa / deploy-phpmyadmin.sh
Created July 4, 2019 18:52
Deploy PHP MyAdmin using PHP Cloud Native Buildpacks
#!/bin/bash
#
# See https://mikusa.blogspot.com/2019/07/php-cloud-native-buildpacks.html
#
# create private bridge network
docker network create -d bridge test-app-bridge
# create db
docker run --name test-db --network test-app-bridge -e MYSQL_ROOT_PASSWORD=hacKm3 -d percona
@dmikusa
dmikusa / find_app.sh
Created June 24, 2019 13:54
Find an app on Cloud Foundry with the exact app name given. Searches through all apps visible to the currently logged in user.
#!/bin/bash
#
# Find an app with an exact name, app must be visible to the logged in user
#
set -e
function load_all_pages {
URL="$1"
DATA=""
until [ "$URL" == "null" ]; do
@dmikusa
dmikusa / inspect-certs.rb
Last active December 22, 2017 16:01
Inspect the certs listed in installation.yml for PCF
#!/usr/bin/env ruby
require 'yaml'
require 'openssl'
def confirm
print " Enter (y/n)... "
begin
while input = STDIN.gets.downcase.strip
case input
when "y"
@dmikusa
dmikusa / README.md
Created August 17, 2017 15:25
Example using Node.js to get an Auth Code from Cloud Foundry's UAA for use with SSH (i.e. same as `cf ssh-code`)

To test this:

  1. Run npm install or yarn install
  2. Run node index.js && ssh -p 2222 cf:$(cf app app-name --guid)/0@ssh.system.domain.com, where app-name is your app name and ssh.system.domain.com is the DNS name of your SSH end point.
  3. When prompted for a password, enter the code listed after Access Code is.

You should now be SSH'd into the given application & instance id.

NOTE: better error handling should be done, but has been omitted to keep this example brief.