Skip to content

Instantly share code, notes, and snippets.

View hiepxanh's full-sized avatar

hiepxanh hiepxanh

View GitHub Profile
@hiepxanh
hiepxanh / README.md
Created May 21, 2018 02:47 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@hiepxanh
hiepxanh / webpack.config.js
Created May 16, 2018 04:27 — forked from GabrielUlici/webpack.config.js
ionic-angular@3.7.0 env fix
var path = require('path');
var useDefaultConfig = require('@ionic/app-scripts/config/webpack.config.js');
var procEnv = process.env.IONIC_ENV;
module.exports = function () {
useDefaultConfig[procEnv].resolve.alias = {
"@app/env": path.resolve('./src/environments/environment' + (process.env.IONIC_ENV === 'prod' ? '' : '.' + process.env.IONIC_ENV) + '.ts')
};
@hiepxanh
hiepxanh / THREE Image Transition.markdown
Created April 22, 2018 05:40
THREE Image Transition
@hiepxanh
hiepxanh / shopee-badge.html
Created April 18, 2018 01:30
badge flag shopee
<div class="item-image">
<div class="shopee-item-card__badge-wrapper">
<div class="shopee-badge shopee-badge--fixed-width shopee-badge--promotion">
<div class="shopee-badge--promotion__label-wrapper shopee-badge--promotion__label-wrapper--vi-VN">
<span class="percent">16%</span>
<span class="shopee-badge--promotion__label-wrapper__off-label shopee-badge--promotion__label-wrapper__off-label--vi-VN">giảm</span>
</div>
</div>
</div>
</div>
@hiepxanh
hiepxanh / groupby.ts
Last active April 7, 2018 03:33
group by code, turn array order buy property
declare global {
interface Array<T> {
groupBy(elem: T): Array<T>;
}
}
Array.prototype.groupBy = function(prop) {
return this.reduce(function(groups, item) {
const val = item[prop]
@hiepxanh
hiepxanh / install.bat
Created April 5, 2018 06:43 — forked from stormoz/install.bat
Start Selenium Grid hub and nodes as Windows services
nssm install SeleniumHub java -jar C:\Selenium\selenium-server-standalone-2.48.2.jar -role hub
nssm start SeleniumHub
nssm install SeleniumNode1 java -jar C:\Selenium\selenium-server-standalone-2.48.2.jar -role node -hub http://localhost:4444/grid/register -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe
nssm set SeleniumNode1 DependOnService SeleniumHub
nssm start SeleniumNode1
nssm install SeleniumNode2 java -jar C:\Selenium\selenium-server-standalone-2.48.2.jar -role node -hub http://localhost:4444/grid/register -Dwebdriver.chrome.driver=C:\Selenium\chromedriver.exe
nssm set SeleniumNode2 DependOnService SeleniumHub
nssm start SeleniumNode2
@hiepxanh
hiepxanh / cloudSettings
Created March 14, 2018 07:28
Visual Studio Code Settings Sync Gist
{"lastUpload":"2018-03-14T07:28:48.408Z","extensionVersion":"v2.9.0"}
@hiepxanh
hiepxanh / selenium-js-hover-btn.ts
Created March 7, 2018 09:35
selenium javascript hover button with async await
async login(driver:WebDriver) {
await driver.get('https://tiki.vn');
let loginElement = await driver.findElement(By.id('header-user'));
let strJavaScript = "var element = arguments[0];"
+ "var mouseEventObj = document.createEvent('MouseEvents');"
+ "mouseEventObj.initEvent( 'mouseover', true, true );"
+ "element.dispatchEvent(mouseEventObj);";
await driver.executeScript(strJavaScript, loginElement);
}
@hiepxanh
hiepxanh / getHTML.ts
Created February 8, 2018 07:41
get HTML request
getHTML() {
return this.http.request('GET','api/account/login',{observe:'response',responseType:'text'})
.map((res:HttpResponse<any>) => { console.log(res.body); return res.body })
}
@hiepxanh
hiepxanh / api.ts
Last active February 8, 2018 07:42
themeable Browser for ionic
cssVariable: string = `
#header, #breadcrumb-wrapper, #footer,#mobile-bottom-navigation, #back-to-top {
display:none;
}
body {
padding-bottom: 80px;
padding-top: 1px;
}
`