Skip to content

Instantly share code, notes, and snippets.

View mcbhenwood's full-sized avatar

Mark Henwood mcbhenwood

View GitHub Profile
import hashlib
EXAMPLE_COMPANY = {"name": "Acme Ltd", "id": 1234}
short_hash_of_id = hashlib.sha256(
str(EXAMPLE_COMPANY["id"]).encode("utf-8")
).hexdigest()[:7]
print(f"Folder name: {EXAMPLE_COMPANY['name']} ({short_hash_of_id})")
@mcbhenwood
mcbhenwood / google_drive_poc.py
Last active August 15, 2021 10:38
Example code for uploading a file to Google Drive via Google Drive API
#!/usr/bin/env python3
#
# POC to call Google Drive API as a headless process
# --------------------------------------------------
from googleapiclient.discovery import build
from googleapiclient.http import MediaFileUpload
from google.oauth2 import service_account
SCOPES = ['https://www.googleapis.com/auth/drive']
SERVICE_ACCOUNT_FILE = 'keyfile.json' # Downloaded from GCP Service Account detail page

Keybase proof

I hereby claim:

  • I am mcbhenwood on github.
  • I am mcbhenwood (https://keybase.io/mcbhenwood) on keybase.
  • I have a public key ASCuAvFtJWAdwZ4hBI_Qt8BgE_yt0vns_tJZy9H-TtJrHQo

To claim this, I am signing this object:

@mcbhenwood
mcbhenwood / dr.sh
Created March 2, 2016 10:53
Bash shortcut to grep running Docker container names and stop then remove any which match
#!/bin/bash
docker rm $( docker stop $(docker ps -a | grep $1 | awk '{ print $1; }'))
@mcbhenwood
mcbhenwood / bower.json
Last active November 9, 2015 10:15
How to specify dependencies manually within bower.json, in particular how to get jQuery to load before AngularJS.
"dependencies": {
"angular": "1.3.x",
"angular-bootstrap": "0.14.x",
"angular-resource": "1.3.x",
"angular-route": "1.3.x",
"bootstrap": "3.3.x",
"jquery": "2.1.1",
"moment": "^2.8.4",
"Chart.js": "2.0.0-alpha2"
},
@mcbhenwood
mcbhenwood / foo.config
Created December 9, 2013 11:47
Elasticbeanstalk .config file additions which cause mysterious errors
- namespace: aws:elb:loadbalancer
option_name: LoadBalancerHTTPPort
value: OFF
- namespace: aws:elb:loadbalancer
option_name: LoadBalancerHTTPSPort
value: 443
- namespace: aws:elb:loadbalancer
option_name: LoadBalancerSSLPortProtocol
@mcbhenwood
mcbhenwood / environment.py
Created November 8, 2012 15:50
Simple Behave environment file to start Selenium webdriver
"""
Hooking up Selenium to Behave.
For details, see:
http://pyuseful.wordpress.com/2012/11/08/running-cucumber-style-tests-in-django-using-behave/
"""
import logging
from selenium import webdriver
@mcbhenwood
mcbhenwood / run_customer_tests.py
Created November 8, 2012 15:43
Run Selenium tests against the django test server, from command line with no GUI
"""
Run Selenium headless tests against Django test server
------------------------------------------------------
Creates and destroys a test environment each time.
Requires Xvfb and IceWeasel to be installed. For Debian flavours:
sudo apt-get install xvfb iceweasel