Skip to content

Instantly share code, notes, and snippets.

Avatar

Hwee-Boon Yar hboon

View GitHub Profile
@hboon
hboon / code.markdown
Last active Apr 11, 2020
self when initialising property with function, inheriting from NSObject
View code.markdown

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 Apr 11, 2020
self when initialising property with function, inheriting from NSObject
View code.swift
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 Sep 16, 2019
List of checks against web site and web services
View gist:ba1e0b7e316fcddf4354c27349f0c0b4
* 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 Sep 16, 2019
List of lint checks that would be good for TokenScript files
View gist:21ae39d77b8ded461cb4cbce1656370a
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 Jun 19, 2019 — forked from steipete/gist:d9b44d8e9f341e81414e86d7ff8fb62d
Using iOS 13 devices with Xcode 10.2 (instead of Xcode 11)
View gist:45dbd21537a5564b975420527e9eed7f
// 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 Jun 18, 2019 — forked from insidegui/WebCacheCleaner.swift
Clear WKWebView's cookies and website data storage, very useful during development.
View WebCacheCleaner.swift
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 Jan 31, 2019
Test Solidity/EVM input encoding
View testFunctionCallEncoding.js
let abi = {
"name" : "balanceOf",
"stateMutability" : "view",
"outputs" : [
],
"inputs" : [
{
"name" : "expiry",
"type" : "uint256"
},
@hboon
hboon / jscore.md
Created Jul 16, 2018 — forked from mheiber/jscore.md
Using JavaScriptCore in a Production iOS app
View jscore.md

JavaScriptCore is a built-in iOS library that enables you to use JavaScript in apps alongside Objective-C and Swift. It lets developers read JavaScript from a string, execute it from Objective-C or Swift, and share data structures and functions across languages. We JavaScriptCore to share code between Web and iOS.

Sharing code helped us produce a high-quality, consistent experience across devices while iterating rapidly.

This post is about why we chose to use JavaScriptCore and what we learned. The biggest challenges to using JavaScriptCore in a production app were performance optimization for older devices and getting the build process right. Luckily, these problems have simple solutions that just weren't documented.

Why did we use JavaScriptCore?

A killer feature of one of our apps is search that is optimized for finding guests by name. Our goals included:

@hboon
hboon / wip.md
Created Feb 8, 2018
An example of wip.md
View wip.md

6 Feb

Location: Home Notes: Productive with 0 pomodoros

11:04 PM - 11:07 PM Plan 11:10 PM Mimic

::Mimic

@hboon
hboon / 20180206.md
Created Feb 8, 2018
An example of an archived wip.md
View 20180206.md

6 Feb

Location: Home Notes: Productive with 2 pomodoros

11:04 PM - 11:07 PM Plan 11:10 PM - 11:21 PM Mimic 11:21 PM - 12:03 AM Sales 02:19 PM - 03:32 PM Mimic 04:36 PM - 04:47 PM Mimic

You can’t perform that action at this time.