Skip to content

Instantly share code, notes, and snippets.

@kctang
kctang / tailwind-angular
Created October 25, 2020 02:53
Tailwind CSS support in Angular 10, with Angular Material
Index: client/angular.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- client/angular.json (revision fcfaf7440d0eaed6baa841b2b4d9eca231b002f6)
+++ client/angular.json (date 1603593891228)
@@ -39,7 +39,7 @@
"prefix": "app",
"architect": {
// type from list of valid string values
type Category = 'action' | 'comedy' | 'drama'
// simple assignment (with IDE auto-complete)
const myCategory: Category = 'comedy'
const chooseCategory = () => {
// BAD: repeat the list of categories for selection
const categories = ['action', 'comedy', 'drama']
return categories[1]
@kctang
kctang / AuthHttpInterceptor.ts
Created January 25, 2019 10:17
AuthHttpInterceptor.ts
import {
HttpEvent, HttpEventType, HttpHandler, HttpInterceptor, HttpRequest
} from '@angular/common/http'
import { Injectable } from '@angular/core'
import { Observable, of } from 'rxjs'
import { concatMap, take } from 'rxjs/operators'
// --- NGXS stuff to read/write access token and refresh token
// --- replace it with your own implementation if you are not using NGXS
import { Select, Store } from '@ngxs/store'
import { AuthState } from '../auth/states/Auth.state'
@kctang
kctang / observables-test.js
Created March 1, 2017 12:57
observables-test.js
console.log('Observables experiment...');
const ob1 = Observable.create((observer: Observer<number>) => {
observer.next(1);
observer.next(2);
observer.complete();
});
const ob2 = num => {
return Observable.create((observer: Observer<number>) => {
console.log(`from num ${num}`);
observer.next(4);
@kctang
kctang / .editorconfig
Last active September 21, 2017 11:03
sample frontend config #archive
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
define([], function () {
'use strict';
var Class = function (classProp) {
var parentClass = classProp.extends;
var Clazz = function (attributes) {
// load default values from class attributes
attributes = defaults(attributes, classProp.attributes);
@kctang
kctang / designer.html
Last active August 29, 2015 14:12
designer
<link rel="import" href="../core-scaffold/core-scaffold.html">
<link rel="import" href="../core-header-panel/core-header-panel.html">
<link rel="import" href="../core-menu/core-menu.html">
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../core-icon-button/core-icon-button.html">
<link rel="import" href="../core-toolbar/core-toolbar.html">
<link rel="import" href="../core-menu/core-submenu.html">
<polymer-element name="my-element">
doctype
html
head
script(rel='import', src='bower_components/platform/platform.js')
link(rel='import', href='bower_components/polymer/polymer.html')
link(rel='import', href='bower_components/core-localstorage/core-localstorage.html')
body
my-app
polymer-element(name='my-app')
template
@kctang
kctang / designer.html
Created June 28, 2014 00:45
designer
<link rel="import" href="../core-pages/core-pages.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
height: 100%;
@kctang
kctang / pom.xml
Last active December 23, 2015 15:39
Using Groovy in Maven projects.
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- reference - http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven -->
<dependencies>
<dependency>