Skip to content

Instantly share code, notes, and snippets.

View apptects's full-sized avatar
🤓
Learning all day...

Gero Gerber apptects

🤓
Learning all day...
View GitHub Profile
@apptects
apptects / receiptvalidator.go
Last active December 13, 2022 16:10
Receipt validation on server side
package main
import (
"bytes"
"encoding/json"
"fmt"
"github.com/gorilla/mux"
"log"
"net/http"
)
@apptects
apptects / Receipt.swift
Created February 5, 2019 09:43
Send receipt validation request to server
struct ReceiptData: Codable {
let receipt: String
let sandbox: Bool
}
struct AppStoreValidationResult: Codable {
let status: Int
let environment: String
}
@apptects
apptects / Receipt.swift
Created February 5, 2019 09:31
Read app's receipt and determine environment
func readReceipt() -> (Receipt: Data, IsSandbox: Bool) {
let receiptURL = Bundle.main.appStoreReceiptURL!
// We are running in sandbox when receipt URL ends with 'sandboxReceipt'
let isSandbox = receiptURL.absoluteString.hasSuffix("sandboxReceipt")
let receiptData = try! Data(contentsOf: receiptURL)
return(receiptData, isSandbox)
}
@apptects
apptects / SomeMonoBehaviour.cs
Created January 29, 2019 17:28
Asset-loading code making use of signpost interval
private IEnumerator LoadSpriteAsync(string _assetName)
{
var sid = Signposts.start_interval_load_asset(_assetName);
var request = Resources.LoadAsync<Sprite>(_assetName);
yield return request;
Signposts.stop_interval_load_asset(sid);
}
@apptects
apptects / Signposts.cs
Last active January 29, 2019 17:34
C# signpost stub methods
using System.Runtime.InteropServices;
public static class Signposts
{
[DllImport ("__Internal")]
private static extern void initialize_log_handles();
[DllImport("__Internal")]
public static extern ulong start_interval_load_asset(string _assetPath);
@apptects
apptects / signpost.h
Last active January 29, 2019 17:14
os_signposts functions
#define os_signpost_event_emit(log, event_id, name, ...)
#define os_signpost_interval_begin(log, interval_id, name, ...)
#define os_signpost_interval_end(log, interval_id, name, ...)
@apptects
apptects / signposts.mm
Last active January 29, 2019 18:07
Native plugin for os_signposts
#import <os/signpost.h>
// We need to specify a subsystem
#define SUBSYSTEM "de.apptects.signposts"
// Categories helps us structuring the data in Instruments
#define CATEGORY_ASSETLOADING "Asset Loading"
#define CATEGORY_INPUT "Input"
// Interval names