Skip to content

Instantly share code, notes, and snippets.

View hiepxanh's full-sized avatar

hiepxanh hiepxanh

View GitHub Profile
@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 / 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 / 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 / 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 / iframe.html
Last active May 23, 2018 01:43
iframe with postMessage
<!-- http://pbojinov.github.io/iframe-communication/iframe.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>iframe Window</title>
<style>
body {
background-color: #D53C2F;
color: white;
@hiepxanh
hiepxanh / myDemo.json
Last active June 28, 2018 10:23
myDemo.json
[
{
"content": [
{
"name": "logo",
"title": "Logo",
"type": "file",
"value": "https://theme.hstatic.net/1000278055/1000356434/14/logo.png?v=1653",
"href": "#123"
@hiepxanh
hiepxanh / demo_product.json
Created July 3, 2018 08:39
demo_product.json
{ "products": [ { "id": 1011873625, "title": "Garlic Bread", "featured_image": "//product.hstatic.net/1000259614/product/upload_b585232256ae43f9bb79be0437d6e165_large.jpg", "handle": "garlic-bread", "compare_at_price": 16000000, "compare_at_price_format": "160,000₫", "price": 14000000, "price_format": "140,000₫", "available": true, "sale": "-13%" } , { "id": 1011828140, "title": "PEPPER SPAGHETTI", "featured_image": "//product.hstatic.net/1000259614/product/upload_b16978af13134090bac7d2bb1bf187f1_large.jpg", "handle": "pepper-spaghetti", "compare_at_price": 0, "compare_at_price_format": "0₫", "price": 15000000, "price_format": "150,000₫", "available": true, "sale": "-0%" } , { "id": 1011873657, "title": "Salmon Salad", "featured_image": "//product.hstatic.net/1000259614/product/garden-salad_large.png", "handle": "salmon-salad", "compare_at_price": 18000000, "compare_at_price_format": "180,000₫", "price": 15700000, "price_format": "157,000₫", "available": true, "sale": "-13%" } , { "id": 1011828057, "title": "
@hiepxanh
hiepxanh / app.component.ts
Created July 16, 2018 01:57
firebase clould message
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { TabsPage } from '../pages/tabs/tabs';
import { FCM } from '@ionic-native/fcm';
import { ApiProvider } from '../providers/api/api';
@Component({
// from here:
// @HostListener('document:click', ['$event'])
// clickout(event) {
// console.log("target?",event.target);
// if(this.eRef.nativeElement.contains(event.target)) {
// console.log("clicked inside",event);
// } else {
// console.log("clicked outside",event);
@hiepxanh
hiepxanh / vscodeOpenFolder.reg
Created July 27, 2019 02:18
Visual Studio Code (VSCode) open Folder as Visual Code Project
Windows Registry Editor Version 5.00
; Open files
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code]
@="Edit with VS Code"
"Icon"="C:\\Users\\hiepx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe,0"
[HKEY_CLASSES_ROOT\*\shell\Open with VS Code\command]
@="\"C:\\Users\\hiepx\\AppData\\Local\\Programs\\Microsoft VS Code\\Code.exe\" \"%1\""
; This will make it appear when you right click ON a folder
; The "Icon" line can be removed if you don't want the icon to appear
[HKEY_CLASSES_ROOT\Directory\shell\vscode]