Skip to content

Instantly share code, notes, and snippets.

Avatar

Benjamin Charity benjamincharity

View GitHub Profile
View textMaskCore.js
!(function (e, r) {
"object" == typeof exports && "object" == typeof module ? (module.exports = r()) : "function" == typeof define && define.amd ? define([], r) : "object" == typeof exports ? (exports.textMaskCore = r()) : (e.textMaskCore = r());
})(this, function () {
return (function (e) {
function r(n) {
if (t[n]) return t[n].exports;
var o = (t[n] = { exports: {}, id: n, loaded: !1 });
return e[n].call(o.exports, o, o.exports, r), (o.loaded = !0), o.exports;
}
var t = {};
View ep.html
<div [@detailExpand]="shouldExpand ? 'expanded' : 'collapsed'">
Test
</div>
View skip-ci.yml
- name: Set SHOULD_RUN flag
run: |
if [[ "${{github.event.head_commit.message}}" =~ (skip\ ci|ci\ skip) ]]; then
echo "::set-env name=SHOULD_RUN::false"
else
echo "::set-env name=SHOULD_RUN::true"
fi
- name: Manual build
run: yarn library:build:prod
if: env.SHOULD_RUN == 'true'
View strikethrough.js
{
const sheet = window.document.styleSheets[0];
const rule = '.task-list-item-checkbox:checked+.task-list-item-text{opacity:.5;text-decoration:line-through;}';
sheet.insertRule(rule, sheet.cssRules.length);
const listItems = document.querySelectorAll('.task-list-item');
Array.from(listItems).forEach(item => {
const nodes = Array.from(item.childNodes).filter(item => item instanceof Text || item.tagName === "CODE");
const checkbox = item.querySelectorAll('input')[0];
const originalText = nodes.map(node => node.nodeValue || node.textContent).join('').trim();
View component.ts
public readonly headerCellResizes: Observable<TsHeaderCellResizeEvent> | Observable<{}> = defer(() => {
if (this.headerCells && this.headerCells.length) {
return merge(...this.headerCells.map(cell => cell.resized));
}
// If there are any subscribers before `ngAfterViewInit`, `headerCells` may be undefined.
// In that case, return a stream that we'll replace with the real one once everything is in place.
return this.ngZone.onStable
.asObservable()
.pipe(take(1), switchMap(() => this.headerCellResizes));
View qeury.ts
public queryStates(query: string): State[] {
query = query.toLowerCase();
if (query) {
const letters = query.split('').map(l => `${l}.*`).join('');
const regex = new RegExp(letters, 'ig');
return this.states.filter(s => !!s.name.match(regex));
} else {
// if no query, return first 10 states
return STATES.slice(0, 10);
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
View optionalTemplateExample.html
<ng-content *ngIf="!optionTemplate">
</ng-content>
<ng-container
*ngIf="optionTemplate"
[ngTemplateOutlet]="optionTemplate"
[ngTemplateOutletContext]="{$implicit: option}"
></ng-container>
View keyofError.sh
BUILD ERROR
ngx-tools/src/jwt-token-managment/reducer.ts(33,7): error TS2536: Type 'keyof C' cannot be used to index type '{ [x: string]: string; }'.
ngx-tools/src/jwt-token-managment/utilities/token-extractor.mock.ts(34,10): error TS2416: Property 'extractJwtToken' in type 'TokenExtractorMock<CM>' is not assignable to the same property in base type 'TokenExtractor<ClaimMap>'.
Type '<T extends Object | HttpResponse<any>>({ tokenName, isDefaultToken }: ExtractTokenParams<CM>) => ...' is not assignable to type '<T extends Object | HttpResponse<any>>({ tokenName, resetAllOtherTokens, isDefaultToken }: Extrac...'.
Types of parameters '__0' and '__0' are incompatible.
Type 'ExtractTokenParams<ClaimMap>' is not assignable to type 'ExtractTokenParams<CM>'.
Types of property 'tokenName' are incompatible.
Type 'string | number' is not assignable to type 'keyof CM'.
Type 'string' is not assignable to type 'keyof CM'.
ngx-tools/src/jwt-token-managment/utilities/retry-with-escala
@benjamincharity
benjamincharity / custom-date-adapter.ts
Created Aug 28, 2018
Custom date adaptor for material
View custom-date-adapter.ts
import { NativeDateAdapter } from '@angular/material/core';
export const TS_DATE_FORMATS = {
parse: {
dateInput: {month: 'short', year: 'numeric', day: 'numeric'},
},
display: {
dateInput: 'input',
monthYearLabel: 'inputMonth',
You can’t perform that action at this time.