Skip to content

Instantly share code, notes, and snippets.

View bretmcg's full-sized avatar

Bret McGowen bretmcg

View GitHub Profile
@bretmcg
bretmcg / deploy.sh
Last active November 22, 2023 02:41
Call Google Cloud Functions from HTML / Browser
#!/bin/bash
# 1. After deploy, update the function URL in index.html
# 2. If you rename myCloudFunction, change it here, index.js and index.html
# 3. The HTML file must be served from a server
# (or locally via something like $ python3 -m http.server)
gcloud functions deploy myCloudFunction \
--gen2 \
--runtime=nodejs20 \
--region=us-central1 \
--source=. \
@bretmcg
bretmcg / call-ml-engine-index.js
Last active February 3, 2020 19:54
Call Cloud ML Engine from Google Cloud Functions
// Copyright 2018, 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,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@bretmcg
bretmcg / speech_api.sh
Last active September 13, 2018 09:49
Call the Google Cloud Speech API from command line
#!/bin/bash
# This is not an official Google product.
# Copyright 2016 Google Inc. All Rights Reserved.
#
# 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
#
@bretmcg
bretmcg / gist:5869717
Last active December 19, 2015 00:38
MySQL Cron Backup: Can be placed in the /etc/cron.hourly folder (make sure file is executable) to take a MySQL backup and dump to a file
cd /home/bret/db_backups
DATE=$(date +"%Y%m%d%H%M")
# Export the MySQL database
mysqldump -u backup_user -p secret_password --all-databases | gzip --rsyncable > backup_db_$DATE.sql.gz
# Keep at most 30 files
ls -t | sed -e '1,30d' | xargs -d '\n' rm