Skip to content

Instantly share code, notes, and snippets.

View grant's full-sized avatar

Grant Timmerman grant

View GitHub Profile
@grant
grant / routes.swift
Created June 29, 2020 18:24
Vapor Routes
import Vapor
func routes(_ app: Application) throws {
app.get { req in
return "It works!"
}
app.get("hello") { req -> String in
return "Hello, world!"
}
=======================
==== request start ====
uri: https://serviceusage.googleapis.com/v1/projects/my-project/services?alt=json&filter=state%3AENABLED
method: GET
== headers start ==
b'Authorization': --- Token Redacted ---
b'accept': b'application/json'
b'accept-encoding': b'gzip, deflate'
b'content-length': b'0'
b'user-agent': b'google-cloud-sdk gcloud/HEAD command/gcloud.services.list invocation-id/why-are-you-looking-at-this? environment/None environment-version/None interactive/True from-script/False python/3.7.3 term/xterm-256color (Macintosh; Intel Mac OS X 19.4.0)'
gcloud services list --log-http
PROJECT_ID=$(gcloud projects list \
--filter="$PROJECT_NUMBER" \
--format="value(project_id)")
echo $PROJECT_ID
PROJECT_NUMBER=$(gcloud projects list \
--filter="project_id:$PROJECT_ID" \
--format='value(project_number)')
echo $PROJECT_NUMBER
RUN_SERVICE=helloworld
RUN_SERVICE_URL=$(gcloud run services describe $RUN_SERVICE --format 'value(status.address.url)')
curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" $RUN_SERVICE_URL
gcloud beta billing projects describe \
$(gcloud config get-value project) \
--format="value(billingEnabled)"
# Set project
gcloud config set project "my-project"
# Get project
PROJECT=$(gcloud config get-value core/project 2> /dev/null)
@grant
grant / call.sh
Created June 9, 2020 00:03
Call a .NET function
RUN_SERVICE=$(gcloud run services describe hellodotnet --format 'value(status.address.url)')
curl -H "Authorization: Bearer $(gcloud auth print-identity-token)" $RUN_SERVICE
@grant
grant / Dockerfile
Created June 8, 2020 22:25
.NET FF Dockerfile
# Use Microsoft's official build .NET image.
# https://hub.docker.com/_/microsoft-dotnet-core-sdk/
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /app
# Install production dependencies.
# Copy csproj and restore as distinct layers.
COPY *.csproj ./
RUN dotnet restore