Skip to content

Instantly share code, notes, and snippets.

package org.apache.catalina.nonblocking;
import java.io.IOException;
import java.nio.CharBuffer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.AsyncContext;
import javax.servlet.ReadListener;
@dmikusa
dmikusa / pom.xml
Created April 22, 2014 17:49
Example Maven configuration for using Spring Insight Annotations
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pivotal.demos</groupId>
<artifactId>demos-insight-annotations</artifactId>
<name>MyApp</name>
<packaging>war</packaging>
<version>1.0.0-BUILD-SNAPSHOT</version>
<dependencies>
@dmikusa
dmikusa / cfenv.sh
Last active August 29, 2015 14:02
A handy function that you can add to your profile for managing connections to different CloudFoundry instances.
function cfenv () {
function curenv () {
if [ "$1" == "" ]; then
CURENV="default"
else
CURENV="$(echo "$1" | cut -d '-' -f 2)"
fi
}
function listenvs () {
echo "Listing available environments..."
@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.

@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 / 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 / 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
#!/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 / 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;