Skip to content

Instantly share code, notes, and snippets.

ryderdamen / Dockerfile
Created January 21, 2020 19:24
The Dockerfile for running our cat facts app.
View Dockerfile
FROM python:3.7-alpine
COPY ./src/requirements.txt /code/requirements.txt
RUN pip install -r requirements.txt
COPY ./src .
CMD [""]
ryderdamen / requirements.txt
Created January 21, 2020 17:58
An example requirements.txt file for our flask app that displays cat facts.
ryderdamen /
Last active January 21, 2020 19:26
An example flask application for retrieving and displaying facts about cats.
import os
from flask import Flask, render_template
import requests
app = Flask(__name__)
def get_cat_fact():
cat_facts_url = ''
response = requests.get(cat_facts_url)
ryderdamen / config.yml
Created January 20, 2020 17:12
An example CircleCI Config file for deploying a Google Cloud Function
View config.yml
version: 2
- image: google/cloud-sdk
- checkout
- run:
name: Authorize GCloud Command Line Tool
command: |
ryderdamen /
Created October 22, 2019 15:01
An example of a function that tests if a connection to Redis can be established.
import os
import redis
def can_connect_to_redis():
if not os.environ.get('REDIS_URL'):
return False
conn = redis.from_url(os.environ.get('REDIS_URL'))
return True
ryderdamen /
Last active February 28, 2022 19:56
An example of how to calculate takeoff distance for a Cessna 150. This is an example only.

Calculating Takeoff Distance - Cessna 150

This document is an example for how to calculate takeoff distance for a Cessna 150. Please note, this is an example only. Consult the Pilot Operating Handbook (POH) for your particular airplane for doing real-life calculations. This example assumes you are a Canadian pilot - the logic is all the same as everywhere else, the lookup locations are different.


To calculate landing distance, the following general steps need to be done.

  1. Calculate pressure altitude
  2. Calculate temperature at altitude
  3. Calculate headwind component
  4. Look up and calculate takeoff distance
ryderdamen /
Last active August 10, 2021 17:08
How to trigger a Cron Job manually on Kubernetes

Triggering a Cron Job manually on Kubernetes

So you've defined a cronjob.yaml manifest, but it doesn't run until midnight and you want to test it now? Simply replace the variables, and run the following command to create a job from the cronjob.

kubectl create job --from=cronjob/{{ cron_job_name }} {{ the-name-of-this-one-off-job }}

This will create a one-off job in your cluster based on your cronjob.yaml manifest, which might look something like this.

apiVersion: batch/v1beta1
View nginx-neo4j-proxy-config-base
# Standard Neo4J Reverse Proxy Docker Container
# Forwards traffic to Neo4J Docker Container (with mounted TLS certs)
server {
location / {
proxy_set_header Host $host;
proxy_redirect off;
ryderdamen /
Created December 4, 2018 15:43
Uploading Files from Google Compute Engine (GCE) VMs to Google Cloud Storage (GCS)

Uploading Files from Google Compute Engine (GCE) VMs to Google Cloud Storage (GCS)

I had a bit of trouble trying to configure permissions to upload files from my Google Compute Engine instance to my Google Cloud Storage bucket. The process isn't as intuitive as you think. There are a few permissions issues that need to be configured before this can happen. Here are the steps I took to get things working.

Let's say you want to upload yourfile.txt to a GCS bucket from your virtual machine. You can use the gsutil command line tool that comes installed on all GCE instances.

If you've never used the gcloud or gsutil command line tools on this machine before, you will need to initialize them with a service account.