Skip to content

Instantly share code, notes, and snippets.

View craigafinch's full-sized avatar

Craig Finch craigafinch

View GitHub Profile
@craigafinch
craigafinch / test_google_bigtable_grpc.php
Created June 5, 2020 20:03
A minimal test script to ensure that a PHP server can access data in Google BigTable (tests scopes, credentials, GRPC, and protobuf)
<?php
require 'vendor/autoload.php';
use Google\Cloud\Bigtable\BigtableClient;
$project_id = 'my-project-id';
$instance_id = 'my-instance-id';
$table_id = 'my-table-id';
$credential_file_path = './credential.json';
$transport = 'grpc';
label:audit before:2019/04/01
@craigafinch
craigafinch / stackdriver-instance-log-filter.txt
Last active March 27, 2018 13:40
Google Stackdriver logging advanced filter to view logs across multiple Compute Engine instances by instance name
resource.type="gce_instance"
logName="projects/my-project-name/logs/apache-error"
labels."compute.googleapis.com/resource_name":"-web-"
textPayload:"execution time"
@craigafinch
craigafinch / mysql2cloudsql.py
Created January 4, 2018 03:09
Export data from MySQL in a form suitable for import into Google Cloud SQL
#!/usr/bin/env python
import subprocess
import os
import datetime
# Get list of views from MySQL
getViews = subprocess.Popen(['mysql', 'core'], stdin=subprocess.PIPE, stdout=subprocess.PIPE)
views = getViews.communicate("SHOW FULL TABLES IN core WHERE TABLE_TYPE LIKE 'VIEW';")[0].strip()
@craigafinch
craigafinch / gcs.service
Last active August 7, 2019 06:37
A systemd service to manage a Google Cloud Storage bucket mounted with GCSFuse
# https://github.com/GoogleCloudPlatform/gcsfuse
[Unit]
Description=Google Cloud Storage FUSE mounter
After=local-fs.target network-online.target google.service sys-fs-fuse-connections.mount
Before=shutdown.target
[Service]
Type=forking
User=apache
@craigafinch
craigafinch / fabfile.py
Last active September 25, 2017 10:01 — forked from alexaivars/fabfile.py
Use fabric with a vagrant instance
from fabric.api import env, local, run
def vagrant():
"""USAGE:
fab vagrant uname
Note that the command to run Fabric might be different on different
platforms.
"""
# change from the default user to 'vagrant'