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 / 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');
}
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;
const { rxObserver } = require('api/v0.3');
const { Observable, ConnectableObservable, GroupedObservable, observable, Subject, BehaviorSubject, ReplaySubject, AsyncSubject, asapScheduler, asyncScheduler, queueScheduler, animationFrameScheduler, VirtualTimeScheduler, VirtualAction, Scheduler, Subscription, Subscriber, pipe, noop, identity, isObservable, ArgumentOutOfRangeError, EmptyError, ObjectUnsubscribedError, UnsubscriptionError, TimeoutError, bindCallback, bindNodeCallback, defer, empty, forkJoin, from, fromEvent, fromEventPattern, generate, iif, interval, never, of, pairs, range, throwError, timer, using, EMPTY, NEVER, config } = require('rxjs');
const { audit, auditTime, buffer, bufferCount, bufferTime, bufferToggle, bufferWhen, catchError, combineAll, combineLatest, concat, concatAll, concatMap, concatMapTo, count, debounce, debounceTime, defaultIfEmpty, delay, delayWhen, dematerialize, distinct, distinctUntilChanged, distinctUntilKeyChanged, elementAt, endWith, every, exhaust, exhaustMap, expand, fil
@tw3
tw3 / lint_modified_lines.js
Last active April 12, 2019 04:29
PR blocker script that returns outputs ESLint messages for lines that have been modified vs git master branch
const Git = require('nodegit');
const CLIEngine = require('eslint').CLIEngine;
/**
* Usage: node lint_modified_lines.js
*
* This script:
* 1. Determines the files and lines that have been added or changed compared to the master branch.
* 2. Runs eslint.
* 3. Filters the lint results to only the lines that have been added or changed.