Skip to content

Instantly share code, notes, and snippets.

View SHANG-TING's full-sized avatar
🏠
Working from home

Neil Xie SHANG-TING

🏠
Working from home
View GitHub Profile

Angular Universal (Webpack bundle + Docker deploy)

Tested with angular@5.

Install deps

npm i @angular/platform-server @nguniversal/express-engine @nguniversal/module-map-ngfactory-loader express @types/express ts-loader@3 rimraf --save-dev

Update src/app/app.module.ts

@SHANG-TING
SHANG-TING / infinite-scroll.directive.ts
Created July 30, 2020 17:21 — forked from lansana/infinite-scroll.directive.ts
This is an Angular 2 infinite scroll directive. It is simple, easy to use and very CPU-efficient.
// USAGE:
//
// When you attach the infiniteScroll directive to an element, it will emit the infiniteScrollAction
// @Output() event every time the user has scrolled to the bottom of the element. Your loadMoreArticles
// function can make an HTTP call and append the results to the articles list, for example. In doing this,
// you effectively increase the height of the element and thus begin the process of the infiniteScroll directive
// again, over and over until the element height stops increasing.
//
// <div class="container" infiniteScroll (infiniteScrollAction)="loadMoreArticles()">
// <div class="article" *ngFor="let article of articles">
{
"orderId": "20200716090931250a5098",
"orderStatus": null,
"type": 1,
"status": 0,
"bookingId": "31",
"pricingId": "202007160909425356-4ce38307-d7c7-404f-960f-236a33575483",
"pricingExpiryDate": "2020/07/17 15:59",
"flights": [
{
@SHANG-TING
SHANG-TING / clipboard-paste-image.js
Created April 15, 2020 12:47 — forked from dusanmarsa/clipboard-paste-image.js
JavaScript - Clipboard API - Paste image handler
var IMAGE_MIME_REGEX = /^image\/(p?jpeg|gif|png)$/i;
var loadImage = function (file) {
var reader = new FileReader();
reader.onload = function(e){
var img = document.createElement('img');
img.src = e.target.result;
var range = window.getSelection().getRangeAt(0);
range.deleteContents();
@SHANG-TING
SHANG-TING / host.js
Created March 11, 2020 13:48 — forked from tuan/host.js
RxJs and window's postMessage for intercommunication
import * as Rx from "rxjs/Rx";
import * as uuid from "uuid";
import {IRequest} from "./common";
let button = document.querySelector("button");
let iframe = document.createElement("iframe");
iframe.src = "/proxy.html";
document.body.appendChild(iframe);
@SHANG-TING
SHANG-TING / vscode-settings.json
Created February 20, 2020 06:51
2020-02-20 VsCode Settings
# VsCode Settings
```json
{
"workbench.iconTheme": "material-icon-theme",
// 終端機設定
"terminal.external.windowsExec": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"terminal.integrated.shellArgs.windows": ["-l"],
// 縮放比例
@SHANG-TING
SHANG-TING / imageRotate.js
Created September 9, 2019 05:57 — forked from crusty/imageRotate.js
image ratate javascript (rotate image 90 degree....)
/* image rotate javascript */
/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Benoit Asselin | http://www.ab-d.fr */
function rotate(p_deg) {
if(document.getElementById('canvas')) {
/*
Ok!: Firefox 2, Safari 3, Opera 9.5b2
{
"workbench.iconTheme": "material-icon-theme",
// 終端機設定
"terminal.external.windowsExec": "D:\\Git\\bin\\bash.exe",
"terminal.integrated.shell.windows": "D:\\Git\\bin\\bash.exe",
"terminal.integrated.shellArgs.windows": ["-l"],
// 縮放比例
"window.zoomLevel": 0,
"editor.mouseWheelZoom": true,
// 字型