Skip to content

Instantly share code, notes, and snippets.

View stephendarling's full-sized avatar

Stephen Darling stephendarling

View GitHub Profile
@stephendarling
stephendarling / Dockerfile
Created June 20, 2020 17:27
Use multiple images in Dockerfile
# Create first image as Builder
FROM node:12.16.1-alpine As builder
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
@stephendarling
stephendarling / docker-compose.yaml
Created June 19, 2020 16:28
Running Plex with docker-compose
version: "2"
services:
plex:
image: linuxserver/plex:latest
container_name: plex
network_mode: host
environment:
- PUID=127 # user id of plex user
- PGID=130 # group id of plex user
- VERSION=docker
@stephendarling
stephendarling / mysql-docker-backup-restore.sh
Created January 23, 2020 11:52 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
import requests
...
# Send REST request with Bearer OAuth2 token
# run_service_url = The https endpoint created automatically by your new Cloud Run service
# token = The response from the step above
request = requests.get(
url = run_service_url,
import requests
import urllib
...
# Exchange JWT token for a google-signed OIDC token
# signed_jwt = Response/return value from previous step
def exchange_jwt_for_token(signed_jwt):
body = {
import time
import jwt
import urllib
...
# Create and return a signed JWT token to the designated service endpoint
# credentials_json = a Python dictionary created by loading your local service account credentials json file
# run_service_url = The https endpoint created automatically by your new Cloud Run service
# ~/src/lib/utilities.py
def concat_strings(a, b)
new_string = str('{} {}'.format(a,b))
return new_string
import json
import requests
api_url = <YOUR FUNCTION HTTP URL>
api_headers = {
"Content-Type": "application/json"
}
api_data = {
'a': 'Stephen',
'b': 'Darling'
@stephendarling
stephendarling / remote_debug.py
Last active November 3, 2018 17:20
Local debugging with print()
import logging
def create_string(a,b):
new_string = str("{}-{}".format(a,b))
# logging(...)
logging.info('create_string(a,b): {}'.format({
'arguments': { a,b },
'result': new_string
}))
return new_string
const dataArray = [
{ key: 1, value: 'c', name: 'celsius', toKelvin: ')+ 273.15', fromKelvin: ')- 273.15'},
{ key: 2, value: 'f', name: 'fahrenheit', toKelvin: '+ 459.67) * 5/9', fromKelvin: ')* 9/5 - 459.67'},
{ key: 3, value: 'r', name: 'rankine', toKelvin: ')*5/9', fromKelvin: ')* 9/5'},
{ key: 4, value: 'k', name: 'kelvin', toKelvin: ')', fromKelvin: ')'}
]
var performConvert = (t,fx) => eval('('+Number(t) + fx)
var convert = (it,iu,tt,tu) => {