Skip to content

Instantly share code, notes, and snippets.

View mitchwongho's full-sized avatar
:atom:
Build > Test > Deploy

Mitchell Wong Ho mitchwongho

:atom:
Build > Test > Deploy
View GitHub Profile
@mitchwongho
mitchwongho / 1README.md
Last active June 1, 2018 14:24
Implement CORS Request Headers in PlayFramework 2.3.x Applications

Introduction

I recently needed to apply CORS (Cross Origin Request Scripting) to a project that I'm working on. If found 2 posts that helped to achieve it:

I combined both to solve my problem: I have a User CRUD (Play!) webservice and a (Play!) web app that services a SPA (Single Page Application). The SPA needs to access the CRUD webservice, but to acheive this, I would need to apply some CORS rules on both applications.

Files

@mitchwongho
mitchwongho / android-basic.js
Last active April 17, 2018 10:56
Appium Android Basic session script
const wdio = require('webdriverio');
// Driver options
const opts = {
port: 4723,
desiredCapabilities: {
platformName: "Android",
platformVersion: "8.0",
deviceName: "Nexus 5X API 26",
app: "ApiDemos-debug.apk",
appPackage: "io.appium.android.apis",
@mitchwongho
mitchwongho / installation.md
Last active April 16, 2018 09:03
Getting Up and Running with Appium
$ brew install node      # get node.js
$ npm install -g appium  # get appium server
$ npm install webdriverio     # get the appium WebDriver client
@mitchwongho
mitchwongho / btcd.conf
Created January 25, 2018 06:38
Lightning & btcd setup
...
; Secure the RPC API by specifying the username and password. You can also
; specify a limited username and password. You must specify at least one
; full set of credentials - limited or admin - or the RPC server will
; be disabled.
rpcuser=w1/AxcoqWFqsey/x7C9drhaaWl8=
rpcpass=zGnTDRT4a7Pzn9j31n6D0c3S0vs=
@mitchwongho
mitchwongho / docker-nsenter
Last active November 29, 2017 15:45
Docker: nsenter
$ docker inspect --format {{.State.Pid}} <CONTAINER_PID>
e.g. $ PID=%(docker inspect --format {{.State.Pid}} <CONTAINER PID>)
$ sudo nsenter --target <pid> --mount --uts --ipc --net --pid /bin/sh
@mitchwongho
mitchwongho / blockstack.id
Created November 10, 2017 18:15
Blockstack ID Github verification
Verifying my Blockstack ID is secured with the address 12fmp8MHaSmzZbR3iu77hysmd9C5zpLKPs https://explorer.blockstack.org/address/12fmp8MHaSmzZbR3iu77hysmd9C5zpLKPs
@mitchwongho
mitchwongho / RealmObjectFetchOnSubscribe.java
Created February 18, 2016 13:09
RealmResult Observable
package com.github.mitchwongho.android.beacon.database.rx;
import android.content.Context;
import android.support.annotation.NonNull;
import io.realm.Realm;
import io.realm.RealmChangeListener;
import io.realm.RealmObject;
import io.realm.RealmResults;
import rx.Observable;
@mitchwongho
mitchwongho / pseudo-enum.java
Created October 28, 2015 08:22
A enum replacement
import com.google.auto.value.AutoValue;
/**
*
*/
@AutoValue
public abstract class PseudoEnum {
public static PseudoEnum MONDAY() {
return new AutoValue_PseudoEnum(0);
@mitchwongho
mitchwongho / build.gradle
Created May 15, 2015 08:36
Automatic Android app versioning using git tags
def tags = "git -C ${rootDir} tag".execute().text.trim()
def numTags = tags.tokenize('\n').size()
// Fetch the version according to git latest tag and "how far are we from last tag"
def longVersionName = "git -C ${rootDir} describe --tags --long".execute().text.trim()
def (fullVersionTag, versionBuild, gitSha) = longVersionName.tokenize('-')
def(versionMajor, versionMinor, versionPatch) = fullVersionTag.tokenize('.')
// Set the version name
versionName "$versionMajor.$versionMinor.$versionPatch"
@mitchwongho
mitchwongho / mesos-docker
Last active March 1, 2017 19:28
Mesosphere Docker Run Commands
# ZooKeeper
$ sudo docker run --net=host jplock/zookeeper:3.4.6
#Mesos-Master
## It's important to specify --ip=<ip> and --hostname=<ip> parameters
$ sudo docker run --net=host mesosphere/mesos-master:0.21.0-1.0.ubuntu1404 --ip=10.42.0.1 --hostname=10.42.0.1 --zk=zk://10.42.0.1:2181/mesos --work_dir=/opt/ --quorum=1
#Mesosphere-Marathon