Skip to content

Instantly share code, notes, and snippets.

View dino-su's full-sized avatar

Dino Su dino-su

View GitHub Profile
@dino-su
dino-su / promise-queue.js
Last active November 19, 2019 07:34
Fluent Promise Proxy
// Credit: https://gist.github.com/malko/d3dee36e7d0d927654439f4c01c8ca0c
function fluentProxy (target, promise = Promise.resolve()) {
return new Proxy(target, {
get(target, property) {
if (target[property] instanceof Function) {
return (...args) => fluentProxy(target, promise.then(() => target[property](...args)));
}
}
});
@dino-su
dino-su / hello-async.js
Last active February 22, 2019 15:16
async/await request example
const fs = require('fs');
const request = require('request');
function fetch(url) {
return new Promise(function(resolve) {
request(url, function(error, response, body) {
resolve(JSON.parse(body));
});
});
}
@dino-su
dino-su / WinAppDriver.groovy
Last active February 19, 2019 05:57
Jenkins pipeline example of WinAppDriver.
// Credit: https://github.com/Microsoft/WinAppDriver/issues/588
node {
powershell '''
# Start WinAppDrive
Start-Process -FilePath cmd -ArgumentList '/c WinAppDriver.exe 1>WinAppDriver.log 2>WinAppDriver_ERR.log' -WindowStyle Hidden
# Run UI Test
vstest.console.exe 'bin\\Debug\\CalculatorTest.dll'
'''
@dino-su
dino-su / Relaxing-Jenkins-CSP.md
Last active February 23, 2018 03:05
Relaxing Jenkins Content Security Policy.

Jenkins Console

// Allow 'unsafe-inline'
System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", "sandbox; default-src 'none'; img-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';")

// Verify the setting
System.getProperty("hudson.model.DirectoryBrowserSupport.CSP")

Reference

@dino-su
dino-su / README.md
Last active March 16, 2022 07:37
dump HAR with Selenium and Browsermob-Proxy

Package requirement:

  • browsermob-proxy==0.8.0
  • selenium==3.9.0

Usgae: python dump_har.py 'https://www.google.com' | grep mp3

@dino-su
dino-su / m3u8_to_mp4.md
Last active January 10, 2018 09:50
How to download m3u8 stream.
m3u8_to_mp4() {
    url=${1}
    filename=${2}

    ffmpeg -i $url -c copy -bsf:a aac_adtstoasc $filename
}

Usage: m3u8_to_mp4 ${url} ${filename}

@dino-su
dino-su / README.md
Last active July 14, 2019 13:37
Missing Manuals: Waiting without Espresso idling resources.

Sample: Wait for Service

Wait loginComplete = new Wait() {
  @Override
  public Boolean apply() {
    return Service.isLogin() == true;
   }
};

Wait.until(loginComplete);
alias screensaver='open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app'
@dino-su
dino-su / README.md
Last active November 29, 2016 06:18
Android CLI Tips

listing

$ android list sdk --all --extended

update platform tool

$ android update sdk --all --filter platform-tools --no-ui

update build tool

$ android update sdk --all --filter build-tools-24.0.1 --no-ui

update extra tools