Skip to content

Instantly share code, notes, and snippets.

Hwee-Boon Yar hboon

View GitHub Profile
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 /
Created Jul 16, 2018 — forked from mheiber/
Using JavaScriptCore in a Production iOS app

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 /
Created Feb 8, 2018
An example of

6 Feb

Location: Home Notes: Productive with 0 pomodoros

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


hboon /
Created Feb 8, 2018
An example of an archived

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

View iap.rb
# coding: utf-8
class IAPScene < SKScene
include ScreenSizes
attr_accessor :root
def button_size
device_screen_width.fdiv(buttons_per_row + 2)
hboon / nsurlsession_get_plus_basic_auth.rb
Created Jan 28, 2018
GET with NSURLSession + Basic Auth in RubyMotion
View nsurlsession_get_plus_basic_auth.rb
def session_with_basic_auth
return @session_with_basic_auth if @session_with_basic_auth
configuration = NSURLSessionConfiguration.defaultSessionConfiguration.tap do |conf|
any_username_will_do = 'xxx'
userPasswordString = "#{any_username_will_do}: #{api_key}"
userPasswordData = userPasswordString.dataUsingEncoding(NSUTF8StringEncoding)
base64EncodedCredential = userPasswordData.base64EncodedStringWithOptions(0)
authString = "Basic #{base64EncodedCredential}"
#TODO test error handling when authorization is invalid, or when URL is wrong
conf.HTTPAdditionalHeaders = {'Accept'=>'application/json',
hboon / nsurlsession_post.rb
Created Jan 28, 2018
POST with NSURLSession in RubyMotion
View nsurlsession_post.rb
def session
return @session if @session
configuration = NSURLSessionConfiguration.defaultSessionConfiguration.tap do |conf|
conf.HTTPAdditionalHeaders = {'Accept'=>'application/json',
'User-Agent'=> user_agent}
@session = NSURLSession.sessionWithConfiguration(configuration)
hboon / ProgressReporter.swift
Last active Nov 1, 2017
Track how long a function takes to run and report progress
View ProgressReporter.swift
//Get filenames
//Progress 100000/2000000
//Progress 200000/2000000
//Progress 300000/2000000
//Progress 2000000/2000000
//Time taken to get filenames: 100 secs
hboon / using-ipsidekick-with-php.php
Created Oct 15, 2017
Using IP Sidekick for geolocation in PHP
View using-ipsidekick-with-php.php
//Using IP Sidekick for geolocation in PHP
//This uses the free plan which limits you to 1440 lookups/day.
//For a higher rate limit, look at our paid plans at
function resolveIP($ip) {
$string = file_get_contents("{$ip}");
$json = json_decode($string);
hboon / AppleDeviceNamesInEmail.swift
Last active Oct 15, 2017
Use API to include the device name in support emails
View AppleDeviceNamesInEmail.swift
//Using in Swift
//Stick this somewhere
private func deviceModel() -> String? {
var keys = [CTL_HW, HW_MACHINE]
var requiredSize = 0
let fetchSizeResult = sysctl(&keys, UInt32(keys.count), nil, &requiredSize, nil, 0)
guard fetchSizeResult == 0 else { return nil }
You can’t perform that action at this time.