Skip to content

Instantly share code, notes, and snippets.

View alexFaunt's full-sized avatar

Alex Faunt alexFaunt

View GitHub Profile
Bath Organic Farm
Bhangra Bus Cafe
Biblos Wraps
Big Green Breakfast Machine (Open Top Bus)
Buddha Bowl
Buddhafield Cafe
Bunnymans Bunnychow
Burger Bear
Chip Off The Block
Club Mexicana
diff --git a/README.md b/README.md
index 2b34e2a..2a0b245 100644
--- a/README.md
+++ b/README.md
@@ -3,14 +3,13 @@
## Setup
```
-yarn && (cd client && yarn)
+yarn
query1 = `
mutation {
startStreamableWorkout(input: { exerciseSchemaVersion: 1.0 }) {
workout {
exerciseSchema {
version
schema
}
}
}
@alexFaunt
alexFaunt / Query.md
Last active February 28, 2019 16:52

Example mapping

{
  properties: {
    key: { type: 'keyword' },
    title: { type: 'text' },
    
    releases: {
 type: 'nested',
const createModelHelpers = (model) => {
const query = (trx) => model.query(trx).withSchema('workout');
const getById = ({ trx, id }) => query(trx).findById(id);
const insert = async ({ trx, input }) => query(trx).insert(input).returning('*');
return {
query,
@alexFaunt
alexFaunt / SweepstakeTable.js
Created July 21, 2018 10:32
Turn sweepstake teams + results into aggregate table
// Results
const groupStages = [
['Russia', 5, 0, 'Saudi Arabia'],
['Egypt', 0, 1, 'Uruguay'],
['Morocco', 0, 1, 'Iran'],
['Portugal', 3, 3, 'Spain'],
['France', 2, 1, 'Australia'],
['Argentina', 1, 1, 'Iceland'],
['Peru', 0, 1, 'Denmark'],
['Croatia', 2, 0, 'Nigeria'],
{
"notification_type": "RENEWAL",
"environment": "Sandbox",
"password": "APP_STORE_SECRET",
/* The latest receipt information, you should update it in your DB */
"latest_receipt": "ewodnNpZ25...iMCI3d37Cn0=",
/* The decoded information form the latest receipt - an object not array in notifications */
"latest_receipt_info": {
@alexFaunt
alexFaunt / cancel-event.js
Last active June 17, 2018 14:23
Example of an Apple cancel event
{
"notification_type": "CANCEL",
"environment": "Sandbox",
"password": "APP_STORE_SECRET",
/* The date in milliseconds at which the user cancelled */
"cancellation_date_ms": "1528309241000",
/* The latest receipt information, now expired, but you should still update it in your DB */
"latest_expired_receipt": "ewoJVEU1nYXhZO...UNhb2LIjsKfQ==",
@alexFaunt
alexFaunt / verify-receipt.js
Last active April 12, 2019 00:44
Example JS to verify an app store receipt
async verifyReceipt(encodedReceipt) {
const body = JSON.stringify({
'receipt-data': encodedReceipt,
// Set in App Store Connect
password: process.env.APP_STORE_SECRET,
// This means Apple only returns the latest receipt info instead of all transactions.
'exclude-old-transactions': true,
@alexFaunt
alexFaunt / transaction-observer.swift
Created June 17, 2018 12:19
Transaction observer example
switch transaction.transactionState {
case .purchased:
if let appStoreReceiptURL = Bundle.main.appStoreReceiptURL,
FileManager.default.fileExists(atPath: appStoreReceiptURL.path) {
let rawReceiptData = Data(contentsOf: appStoreReceiptURL)
let receiptData = rawReceiptData.base64EncodedString(options: ...)
currentUser.processTransaction(receiptData) { isValid in