Skip to content

Instantly share code, notes, and snippets.

View suhlig's full-sized avatar
😻
Happy

Steffen Uhlig suhlig

😻
Happy
View GitHub Profile
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
# This is an updated version of https://lebkowski.name/docker-volumes
main() {
remove-exited-containers
remove-unused-images
@suhlig
suhlig / switch-fly-version.markdown
Created July 18, 2019 09:57
Switch fly version

I work with a lot of different Concourse servers that have a variety of versions. fly rejects working with servers that are off to much. Therefore I have fly-3.14.1, fly-4.2.3 etc. on my machine.

But many set-pipeline scripts assume that a single fly command exists and that it magically is of the right version. So I need to switch; preferably per directory or per shell.

Did not work

  • Shell aliases are never exported, so that a set-pipeline script does not know about the alias.
  • I use ZSH, where functions cannot be exported.

Works

@suhlig
suhlig / cf-which-org
Created July 12, 2019 07:24
Prints the space and org names for a given route, filtered down to the hostname
#!/usr/bin/env ruby
# Prints the space and org names for a given route, filtered down to the hostname
require 'json'
require 'shellwords'
def curl(url)
while url
JSON.parse(`cf curl #{Shellwords.escape(url)}`).tap do |result|
@suhlig
suhlig / cf-all-apps
Created June 29, 2019 12:10
List all cf apps across all orgs and spaces
#!/usr/bin/env ruby
require 'json'
require 'shellwords'
HIERARCHY = %w(/ org space app)
def curl(url)
while url
JSON.parse(`cf curl #{Shellwords.escape(url)}`).tap do |result|
@suhlig
suhlig / inline-erb.rb
Last active July 20, 2018 18:52
'Blocky' ERB syntax
require 'erb'
class UserTemplate
def initialize(user)
@user = user
end
def to_s
# In the ERB template, we can refer to all instance variables, etc. due to
# the binding being passed.
@suhlig
suhlig / cf-app-lifecycle.markdown
Created December 8, 2017 15:48
Presentation on the Cloud Foundry Application Lifecycle

Cloud Foundry Application Lifecycle

Abstract

What happens between cf push and "state: running"? We will have a look at how the Cloud Foundry part of the IBM Cloud creates and manages applications. Attending this session will give you an in-depth understanding of application deployment works and where to look in case of trouble. (edited)

Happy Day

cd ~/workspace/cf-acceptance-tests/assets/dora
@suhlig
suhlig / gist:89e1cbb183eacb33af6070669cc0eb3e
Last active November 1, 2017 19:34
Multi-line fenced code blocks fail in numbered lists
1. This does not work:
```
$ some command
$ some other command
```
1. This, however, does work fine (note the alignment of 'This' with the block using an extra space):

Freifunk is Down

Log on

  1. Connect the C.H.I.P. via USB to a Mac and execute screen /dev/tty.usbmodem*. It will bring up a serial console (via USB).
  2. Log on (you may have to press Enter before that, so that the login prompt appears)
  3. When done, exit with Control-a, Control-d (where Control-a is the prefix).

Check the WiFi connection

@suhlig
suhlig / keybase.md
Created May 12, 2017 18:58
Keybase proof

Keybase proof

I hereby claim:

  • I am suhlig on github.
  • I am suhlig (https://keybase.io/suhlig) on keybase.
  • I have a public key ASCmKYO26B9hxHc0EXQJzoS4a_NQLrdDiNE3J_BT40XrNQo

To claim this, I am signing this object:

@suhlig
suhlig / parse-cc-logs
Last active June 24, 2016 14:59
Parsing cloud controller logs with jq (also converts time stamps to be human-readable)
cat cloud_controller_ng.log | jq -r '{timestamp: .timestamp|todate, source, message, loc: [.file, .lineno|tostring] | join(":")} | join(" - ")'