Skip to content

Instantly share code, notes, and snippets.

View qmacro's full-sized avatar

DJ Adams qmacro

View GitHub Profile
@qmacro
qmacro / google-oauth
Created May 8, 2024 14:52
Single script to obtain an OAuth bearer token to use in Google API calls
#!/usr/bin/env bash
set -eo pipefail
# CLIENT_ID and CLIENT_SECRET should be in .env
set -a; test -f .env && source .env; set +a
declare REDIRECT_URI="http://127.0.0.1"
declare SCOPE="${SCOPE:-https://www.googleapis.com/auth/spreadsheets}"
declare OAUTH_BASE_URL="https://accounts.google.com/o/oauth2"
@qmacro
qmacro / Dockerfile
Created January 18, 2024 19:00
Dockerfile heredoc test
# syntax=docker/dockerfile:1
# Definition of 'false': 'does nothing, unsuccessfully' (i.e. emits an error exit code)
FROM alpine as old-way
RUN \
echo hello && \
false && \
echo goodbye
*&---------------------------------------------------------------------*
*& Report UI5_REPOSITORY_LOAD
*&
*&---------------------------------------------------------------------*
*&
*& This report implements the up- and download of a SAPUI5 application
*& into an UI5 Repository.
*&
*& Furthermore it is possible to delete a UI5 Repository
*&
@qmacro
qmacro / solution.jq
Created December 2, 2022 14:26
AOC2022 Day 1
#!/usr/bin/env jq
# Run with:
# -R (read raw strings, not JSON texts)
# -s (slurp all inputs into an array)
# i.e. jq -f solution.jq -R -s input.dat
# When initially read in, the input will look like this:
# "1000\n2000\n3000\n\n4000\n\n5000\n6000\n\n7000\n8000\n9000\n\n10000\n"
@qmacro
qmacro / cols.awk
Last active September 29, 2022 00:52
# Output fields in a nicely arranged columnar format.
# Takes two optional variables:
# COLS: comma-separated list of column nrs (fields) to output (default: all)
# GAP: gap required between each column (default: 1)
# Take care of the GAP default
BEGIN {
if (GAP == "") GAP=1
}
@qmacro
qmacro / inserttask.py
Created May 15, 2011 13:54
Sample Task insert using Google API Client library for Python
# Insert a new task into the user's default task list
# Based upon the sample urlshortener.py code for the
# Google API Python Client library
# http://code.google.com/p/google-api-python-client/source/browse/samples/urlshortener/urlshortener.py
# Note that the response to the task insert is a 200, rather than a 201
# If you want to run this, get your own client_id and client_secret using the
# Google API Console https://code.google.com/apis/console/
@qmacro
qmacro / gist:6199973
Last active October 3, 2021 20:19
SheetAsJSON - expose a Google spreadsheet (with a header row) as JSON - See https://qmacro.org/2013/10/04/sheetasjson-google-spreadsheet-data-as-json/ for a writeup
function doGet(request) {
var output = ContentService.createTextOutput();
var data = {};
var id = request.parameters.id;
var sheet = request.parameters.sheet;
var ss = SpreadsheetApp.openById(id);
data["records"] = readData_(ss, sheet);
var callback = request.parameters.callback;
if (callback == undefined) {
output.setContent(JSON.stringify(data));
@qmacro
qmacro / episodes-A.js
Last active April 13, 2020 11:36
Code at Home Ep.8
const episodes = [
{
number: 1,
title: 'Setting up for our first challenge'
},
{
number: 2,
title: 'Fizz-Buzz and Fibonacci'
},
{
@qmacro
qmacro / CheckboxColumnBinding.html
Created February 4, 2014 08:34
Checkbox and Column Visibility binding
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="UTF-8">
<title>Checkbox and Column Binding</title>
<script id="sap-ui-bootstrap"
type="text/javascript"