Skip to content

Instantly share code, notes, and snippets.

@alexamies
alexamies / README.md
Created Mar 12, 2020
How to debug an unresponsive App Engine Flex app
View README.md

How to debug an unresponsive App Engine Flex app

You can debug an unhealthy app using Google Cloud Logging and other GCP tools even if the app has become unresponsive. A test app is provided that simulates the problem in an experiment for the purpose of explaining the debugging process with App Engine Flex.

Prerequisites:

  1. GCP Project with billing enabled
  2. Google Cloud SDK installed
View pie.py
import math
"""Estimates the value of pi
Uses the secant of successivly smaller slices of a unit circle
as an estimate of the circumference
"""
# Initial value is the hypotenuse of a quarter of a circle
# 2pi ~ 4 * srt(2)
# pi ~ 2 * sqrt(2)
@alexamies
alexamies / README.md
Created Dec 20, 2019
App Engine Python 2.7 with Background Thread joined after writing response
View README.md

App Engine Python 2.7 with Threads

Demo os App Engine Python 2.7 with Background thread joined after writing response. Deploy to App Engine with the command:

gcloud app deploy

Browse to the app

@alexamies
alexamies / app.ts
Last active Dec 12, 2019
A TypeScript module to demonstrate redefining console.log with a function that sends the logs to the server.
View app.ts
/**
* Copyright 2017, Google, Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
View alert_policy.json
{
"combiner": "OR",
"conditions": [
{
"conditionAbsent": {
"aggregations": [
{
"alignmentPeriod": "60s",
"crossSeriesReducer": "REDUCE_PERCENTILE_50",
"perSeriesAligner": "ALIGN_DELTA"
View HttpClientApp.java
package io.opencensus.http;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.api.ContentResponse;
/**
* Excercise the Jetty HttpClient
*
*/
public class HttpClientApp {
@alexamies
alexamies / README.md
Last active Oct 16, 2018
Using Chrome Dev Tools with Google Cloud
View README.md

Using Chrome Dev Tools with Google Cloud

This file contains instructions for optimizing a static web site on Google Cloud Platform with Chrome Developer Tools. The final solution is contained in index.html. Intermediate solutions have are given in files index1.html, etc.

Setting up a Static Website on Google Cloud Storage

Static content can be easily hosted on GCP using the GCS features for Hosting a Static Website.

@alexamies
alexamies / README.md
Last active Oct 8, 2018
Wrapping Google Cloud Functions HTTP Triggers in Endpoints
View README.md

Wrapping Google Cloud Functions HTTP Triggers in Endpoints

As the Google Cloud Functions (GCF) ecosystem develops there are many useful examples of functions becoming available. However, it is still kind of hard to lock down the HTTP functions. For example, you may want to add authentication and protect the functions from attacks from the open Internet. On the other hand, Google Cloud Endpoints have been around for a little longer and designed specifically for HTTP access.

@alexamies
alexamies / .eslintrc.json
Last active Oct 5, 2018
Cloud Builder JavaScript Lint Example
View .eslintrc.json
{
"extends": "google"
}
@alexamies
alexamies / README.md
Last active Feb 2, 2021
Using NGINX with Brotli
View README.md

Using NGINX with Brotli

This Gist demonstrates enabling Brotli in Nginx in App Engine Flex using a custom container.

Running in Docker locally

Use of basic Nginx image adapting the example nginx.conf adapted from Full Example Configuration

docker run --rm -itd --name test-nginx \
  -v $(pwd):/usr/share/nginx/html:ro \