Skip to content

Instantly share code, notes, and snippets.

View akingdom's full-sized avatar

Andrew Kingdom akingdom

  • Australia
View GitHub Profile
@akingdom
akingdom / AssetImportRenamer.cs
Last active September 5, 2023 13:46
Maintains a renamed copy of certain Unity Resources asset files in your project. For example, by default Unity won't include SVG files as text XML for further processing.
// Maintains a renamed copy of certain Unity Resources asset files in your project.
// E.g. by default Unity won't include SVG files as XML for further processing.
//
// Put this file in the Assets/Editor folder.
//
// This script automatically rename resource files with a .txt (text) or .bytes (binary) extension,
// to be readable as Resources.Load<TextAssets>(path).text or Resources.Load(path) as byte[].
//
//
// License: CC0
@akingdom
akingdom / DisableUnityAnalytics.cs
Last active September 5, 2023 13:40
Disables sending of device details, etc. to Unity.
/*
* Attach this to any GameObject in the first scene loaded (e.g. the camera).
*
* You can use Charles Proxy to monitor network calls from your game https://support.unity3d.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity
*
* You shouldn't need this if Analytics is disabled in the Services window (which does the same thing as the old Disable HW Stats flag in earlier versions of the Unity Editor). The Analytics Package is not used if Analytics is not enabled.
*
* Ref:
* https://forum.unity.com/threads/unity-iap-without-analytics-for-kids-games.689143/
* https://forum.unity.com/threads/what-happened-to-disable-hw-statistics.961060/
@akingdom
akingdom / inspectablewebkit.m
Created August 13, 2023 12:09
As of iOS 16.4, there is an extra step to allowing a webkit view to be inspected (via remote debugging) from Safari.
#if DEBUG
if (@available(iOS 16.4, *)) {
self.webView.inspectable = true;
}
#endif
@akingdom
akingdom / editable-dropdown-reusable.html
Last active August 13, 2023 10:27
Example of a basic editable HTML dropdown (SELECT menu), aimed at easy use on multiple SELECT elements.
<html>
<!--
This replaces the SELECT dropdown menu with an editable INPUT textbox,
when the last ('other') option is selected from the list.
This version allows adding this functionality to multiple SELECT elements.
(See the 'setupEditableSelectElement' method.)
Note that this may not be a good fit when supplying both display values and raw values,
as evidenced by the 'spanish' option, for example.
@akingdom
akingdom / editable-dropdown.html
Last active August 11, 2023 10:01
Example of a basic editable HTML dropdown (SELECT menu).
<html>
<!--
This replaces the SELECT dropdown menu with an editable INPUT textbox,
when the last ('other') option is selected from the list.
Note that this may not be a good fit when supplying both display values and raw values,
as evidenced by the 'spanish' option.
By Andrew Kingdom (C) 2023 all rights reserved. MIT License.
-->
@akingdom
akingdom / google-drive-link-transform.m
Last active June 5, 2023 09:29
Code snippet to transform a Google Drive link to a directly accessible URL (2023)
@akingdom
akingdom / DynamicMemberLookupExample.swift
Last active May 17, 2023 05:14
Use a string key to reference a property in a class or struct; Get the name of a property as a string
// Demonstrates Swift-based reflection concept like Key-Value coding in Objective-C (but slower)
// and use of @dynamicMemberLookup.
//
// Uses Mirror to reference a property in a class or struct by string key name;
// Uses @dynamicMemberLookup to get the name of a property as a string, to reverse the reflection.
//
// DynamicMemberLookupExample.swift
//
// Copyright Andrew Kingdom 2023-05-17.
// MIT License
@akingdom
akingdom / !Line Record Format.txt
Last active May 29, 2023 16:16
A very simple human-friendly parsable data format. I use this in a number of projects.
# Format Objectives
1. Suitable for editing by humans, especially those with minimal technology skills.
2. Readable by computers.
3. Readability by humans is preferred over reducing file size.
# Basic Format
* The basic line format is a name, some space(s) and a value.
* A record starts with RECORD or # (then an optional identifier).
// Example of printing a source code line at an error position
// (based on an index within the entire source code)
//
// By Andrew Kingdom
// MIT license
// (and use at own risk)
//
// Example prints:
//
// DEFGH