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">
@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 / 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
@SHANG-TING
SHANG-TING / app.module.ts
Created June 28, 2019 16:26 — forked from thiswallz/app.module.ts
Angular 6 Directive to handle wheel events in an input element
//importing directive
import { InputMagicWheelDirective } from 'app/whateverItIs/input-magic-wheel.directive';
//...
//declaring
@NgModule({
declarations: [..., InputMagicWheelDirective],
//...
@SHANG-TING
SHANG-TING / BooleanJsonConverter.cs
Created October 15, 2018 01:37 — forked from randyburden/BooleanJsonConverter.cs
A Json.NET JsonConverter that can handle converting the following values into boolean values: true, false, yes, no, y, n, 1, 0.
using System;
using Newtonsoft.Json;
namespace JsonConverters
{
/// <summary>
/// Handles converting JSON string values into a C# boolean data type.
/// </summary>
public class BooleanJsonConverter : JsonConverter
{
@SHANG-TING
SHANG-TING / jenkins_ci_on_ubuntu.md
Created July 25, 2018 06:23 — forked from ostinelli/jenkins_ci_on_ubuntu.md
Setup Jenkins CI on Ubuntu.

Jenkins CI

Instructions on how to setup a secured Jenkins CI.

Install Jenkins

$ wget -q -O - https://jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
$ sudo sh -c 'echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list$ .d/jenkins.list'
$ sudo apt-get update
$ sudo apt-get install jenkins