Skip to content

Instantly share code, notes, and snippets.

View stewartmcgown's full-sized avatar
💎
making gems

Stewart McGown stewartmcgown

💎
making gems
View GitHub Profile
@stewartmcgown
stewartmcgown / callstackToArray.js
Created November 9, 2018 21:39
Get an array of the JavaScript callstack
class test {
static isPrivate() {
let callername;
try {
throw new Error();
} catch (e) {
/** @type {String[]} */
let stack = e.stack.split("\n");
let out = [];
for (let i = 0; i < stack.length; i++) {
@stewartmcgown
stewartmcgown / partialMatch.js
Created January 15, 2019 12:03
Partial Match properties of Object Array (ES6)
/**
* Are all the values on p present on o
* @param {Object} o object to search
* @param {Object} p object of search values
* @param {Boolean} [c] are loose equality matches ok?
* @return {Boolean} whether there are partial matches
*/
const partialMatch = (o, p, c) =>
Object.keys(p).every(k =>
p[k] && o[k]
@stewartmcgown
stewartmcgown / takeout-discovery.json
Last active March 20, 2024 20:34
Google Takeout API
{
"title": "Takeout API",
"discoveryVersion": "v1",
"ownerName": "Google",
"version_module": true,
"resources": {
"exports": {
"methods": {
"get": {
"flatPath": "v2/{service}/exports/{exportId}",
@stewartmcgown
stewartmcgown / photos-v1.json
Created January 25, 2020 21:01
Google Photos API v1 Internal
{
"canonicalName": "Photos Library",
"auth": {
"oauth2": {
"scopes": {
"https://www.googleapis.com/auth/photoslibrary": {
"description": "View and manage your Google Photos library"
},
"https://www.googleapis.com/auth/photoslibrary.readonly": {
"description": "View your Google Photos library"
@stewartmcgown
stewartmcgown / breathepay-callback.ts
Created April 17, 2020 00:02
BreathePay Various Bits
export interface BreatheCallbackPayload {
/**
* Always A numeric code providing the outcome
* of the transaction:
* Possible values are:
* 0 - Successful / authorised transaction.
* 1 - Card referred – Refer to card issuer.
* 2 - Card referred – Special condition.
* 4 - Card declined – Keep card.
* 5 - Card declined.
{
"vehicle": 1,
"cost": 657,
"description": "{\"riderId\":\"5df8f339-0c16-47bc-b89c-85f02bba0a3f\"}",
"delivery": [
2
],
"amount": [
2
],
@stewartmcgown
stewartmcgown / bigquery.ts
Created September 15, 2021 13:03
Class Transformer Class to BigQuery Schema
import { TableSchema } from '@google-cloud/bigquery';
import { TransformationType } from 'class-transformer';
import { defaultMetadataStorage } from 'class-transformer/cjs/storage';
import { MetadataStorage } from 'class-transformer/types/MetadataStorage';
import { Enum } from './autoenum';
import { ClassType } from './typeorm/class-type';
const meta: MetadataStorage = defaultMetadataStorage;
const BigQueryTypes = Enum(
'STRING',
@stewartmcgown
stewartmcgown / spec.json
Created February 12, 2022 15:30
Google Web SMS Private API
This file has been truncated, but you can view the full file.
{
"version_module": true,
"title": "Instant Messaging Private API",
"ownerName": "Google",
"basePath": "",
"version": "v1",
"resources": {
"group": {
"methods": {
"kickgroupusers": {