Skip to content

Instantly share code, notes, and snippets.

View hboon's full-sized avatar
Indie hacking

Hwee-Boon Yar hboon

Indie hacking
View GitHub Profile
@hboon
hboon / boilerplate.swift
Created December 28, 2022 03:49 — forked from chriseidhof/boilerplate.swift
QuickMacApp
// Run any SwiftUI view as a Mac app.
import Cocoa
import SwiftUI
NSApplication.shared.run {
VStack {
Text("Hello, World")
.padding()
.background(Capsule().fill(Color.blue))
@hboon
hboon / GuardURLProtocol.swift
Created October 14, 2022 07:32 — forked from brunophilipe/GuardURLProtocol.swift
GuardURLProtocol class to monitor all connections initiated by app
//
// GuardURLProtocol.swift
// URLProtocol
//
// Created by Bruno Philipe on 16/2/17.
// Copyright © 2017 Bruno Philipe. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1; then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
exec 1>&2
@hboon
hboon / code.markdown
Last active April 11, 2020 05:47
self when initialising property with function, inheriting from NSObject

Found a bug in my code because of something very subtle:

class C: NSObject {
	var foo: String = {
		NSLog("non-lazy self: \(self)")
		return ""
	}()
	lazy var bar: String = {
 NSLog("lazy self: \(self)")
@hboon
hboon / code.swift
Created April 11, 2020 05:41
self when initialising property with function, inheriting from NSObject
Found a bug in my code because of something very subtle:
```
class C: NSObject {
var foo: String = {
NSLog("non-lazy self: \(self)")
return ""
}()
lazy var bar: String = {
NSLog("lazy self: \(self)")
@hboon
hboon / gist:ba1e0b7e316fcddf4354c27349f0c0b4
Created September 16, 2019 03:27
List of checks against web site and web services
* TokenScript repo is up
* Main homepage is up
* Verify sig API is up and working
* Check express of trust API is up and working
* Any other API is up
* Any other important site is up
@hboon
hboon / gist:21ae39d77b8ded461cb4cbce1656370a
Last active September 16, 2019 02:33
List of lint checks that would be good for TokenScript files
1. Check that in `/token/origins/<ethereum contract="holdingContract">` the string `holdingContract` refers to an existing contract defined in `/token/contract`
ref: https://github.com/AlphaWallet/alpha-wallet-ios/issues/1440
@hboon
hboon / gist:45dbd21537a5564b975420527e9eed7f
Created June 19, 2019 12:25 — forked from steipete/ios-xcode-device-support.sh
Using iOS 13 devices with Xcode 10.2 (instead of Xcode 11)
// The trick is to link the DeviceSupport folder from the beta to the stable version.
// sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
// Xcode 10.2 to Xcode 11 Beta
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/13.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
// Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
@hboon
hboon / WebCacheCleaner.swift
Created June 18, 2019 07:11 — forked from insidegui/WebCacheCleaner.swift
Clear WKWebView's cookies and website data storage, very useful during development.
import Foundation
import WebKit
final class WebCacheCleaner {
class func clean() {
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast)
print("[WebCacheCleaner] All cookies deleted")
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in
@hboon
hboon / testFunctionCallEncoding.js
Created January 31, 2019 03:40
Test Solidity/EVM input encoding
let abi = {
"name" : "balanceOf",
"stateMutability" : "view",
"outputs" : [
],
"inputs" : [
{
"name" : "expiry",
"type" : "uint256"
},