Skip to content

Instantly share code, notes, and snippets.

Avatar

Craig Finch craigafinch

View GitHub Profile
@craigafinch
craigafinch / test_google_bigtable_grpc.php
Created Jun 5, 2020
A minimal test script to ensure that a PHP server can access data in Google BigTable (tests scopes, credentials, GRPC, and protobuf)
View test_google_bigtable_grpc.php
<?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';
@craigafinch
craigafinch / stackdriver-instance-log-filter.txt
Last active Mar 27, 2018
Google Stackdriver logging advanced filter to view logs across multiple Compute Engine instances by instance name
View stackdriver-instance-log-filter.txt
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 Jan 4, 2018
Export data from MySQL in a form suitable for import into Google Cloud SQL
View mysql2cloudsql.py
#!/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 Aug 7, 2019
A systemd service to manage a Google Cloud Storage bucket mounted with GCSFuse
View gcs.service
# 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 Sep 25, 2017 — forked from alexaivars/fabfile.py
Use fabric with a vagrant instance
View fabfile.py
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'