Skip to content

Instantly share code, notes, and snippets.

View tw3's full-sized avatar

Ted Weatherly tw3

  • Austin, TX
View GitHub Profile
@tw3
tw3 / run-node-bash-volume.sh
Created August 22, 2018 13:53
Run a bash shell inside a node docker container with a shared volume
#!/usr/bin/env bash
docker run -it --name container1 -v /home/tweatherly/dir:/home/node/app node:8 bash
# /home/tweatherly/dir is the local machine directory to share
# /home/node/app is the the mapped directory within the node container
#
# you can specify a custom shell instead of node:8, e.g.
# pmoreau/node8-npm5-ngcli:8.9.3-5.5.1-6.0.3
@tw3
tw3 / run-node-bash-volume.sh
Created August 22, 2018 13:53
Run a bash shell inside a node docker container with a shared volume
#!/usr/bin/env bash
docker run -it --name container1 -v /home/tweatherly/dir:/home/node/app node:8 bash
# /home/tweatherly/dir is the local machine directory to share
# /home/node/app is the the mapped directory within the node container
#
# you can specify a custom shell instead of node:8, e.g.
# pmoreau/node8-npm5-ngcli:8.9.3-5.5.1-6.0.3
@tw3
tw3 / run-node-bash-volume.sh
Created August 22, 2018 13:53
Run a bash shell inside a node docker container with a shared volume
#!/usr/bin/env bash
docker run -it --name container1 -v /home/tweatherly/dir:/home/node/app node:8 bash
# /home/tweatherly/dir is the local machine directory to share
# /home/node/app is the the mapped directory within the node container
#
# you can specify a custom shell instead of node:8, e.g.
# pmoreau/node8-npm5-ngcli:8.9.3-5.5.1-6.0.3
@tw3
tw3 / run-node-bash-volume.sh
Created August 22, 2018 13:53
Run a bash shell inside a node docker container with a shared volume
#!/usr/bin/env bash
docker run -it --name container1 -v /home/tweatherly/dir:/home/node/app node:8 bash
# /home/tweatherly/dir is the local machine directory to share
# /home/node/app is the the mapped directory within the node container
#
# you can specify a custom shell instead of node:8, e.g.
# pmoreau/node8-npm5-ngcli:8.9.3-5.5.1-6.0.3
@tw3
tw3 / tidy-templates.js
Last active January 14, 2020 16:28
A node script that lints / reformats Angular template (html) files to a certain standard
/**
* This node js script scans through the input component template files and tidy's them according to certain guidelines.
*
* Sample shell command:
* node tidy-templates.js src/app projects
*
* To disable lint for a template add this comment to the top of the file:
* <!-- tidy-templates: disable -->
*
* Derived from:
@tw3
tw3 / replace_file_snippet.js
Last active August 22, 2018 19:43
A node script that inserts a portion of a snippet file into a section of another file
// Example usage:
// node replace_file_snippet.js \
// inputFile.html '<!--InsertionAreaStart-->' '<!--InsertionAreaEnd-->' \
// snippetFile.html '<!--OptionalSnippetStart-->' '<!--OptionalSnippetEnd-->' \
// outputFile.html
const fs = require('fs');
const path = require('path');
function main() {
@tw3
tw3 / currency-input.directive.ts
Created August 30, 2018 14:52
Currency input directive for Angular
/* tslint:disable:no-forward-ref */
import { OnInit, Directive, HostListener, ElementRef, forwardRef } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
import { I18NCurrencyPipe } from '../pipes';
export const CURRENCY_INPUT_DIRECTIVE_VALUE_ACCESSOR: any = {
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => CurrencyInputDirective),
multi: true
@tw3
tw3 / i18n-currency.pipe.ts
Created August 30, 2018 15:11
Currency pipe for Angular that is i18n friendly, used by my CurrencyInputDirective
import { CurrencyPipe } from '@angular/common';
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'appCurrency'})
export class I18NCurrencyPipe extends CurrencyPipe implements PipeTransform {
constructor() {
// NOTE: This seemingly doesn't change anything, but is required.
super('en');
}
@tw3
tw3 / store.ts
Created March 26, 2019 22:32
Simple state management classes
import { Observable, BehaviorSubject, Subject } from 'rxjs';
export enum StoreState {
INIT,
LOADING,
READY
}
interface StoreInterface<T> {
value$: Observable<T>;
const { rxObserver } = require('api/v0.3');
const { of, timer } = require('rxjs');
const { delay, expand, takeWhile, map } = require('rxjs/operators');
const sessionDuration = 9;
const warningAmount = 7;
const expireEpoch = Date.now() + sessionDuration
const warningEpoch = expireEpoch - warningAmount;