Skip to content

Instantly share code, notes, and snippets.


Thomas Burleson ThomasBurleson

View GitHub Profile
ThomasBurleson /
Last active February 23, 2020 16:04
Git - Benefits of Flat Commit History

Flawed Commit Strategy

Developers often want to condense their git log output. However without a proper git commit strategy (and conventions), those condensed outputs are still flawed.

For details on condensed git log outputs, see Improve your Git Log Output

Consider a git lg output for a typical project:


View Tuples with
export interface ResponseError = [any, Error];	// Tuple to return either 

 * special promise trap to build tuple of reponse and error
const trap = (promise): Promise<ResponseError> => {  
  return promise
 .then(data =&gt; ([data, undefined]))
ThomasBurleson / books-page.component.ts
Last active December 28, 2019 17:03
Compressing View Logic with Facades
View books-page.component.ts
* Snippet from blog article:
selector: 'abl-books-page',
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
ThomasBurleson /
Last active December 5, 2019 15:05
Refactor #4: RxJS Memory Leaks, Zombie Subscriptions, & Errors

💚 Best Practices: Avoid 3 Common RxJS Issues

Bad-RxJS Issues

Developers often find scenarios where they are compelled to manaully subscribe to Observables in View components; these scenarios do not use the async pipe levels of manual subscription management. These manual subscriptions can lead to:

  • Observables + memory leaks, and
  • Zombie subscriptions
ThomasBurleson / BarChart.js
Last active October 9, 2019 15:13
Reusable Chart component for D3 - using prototypes and factories
View BarChart.js
(function() {
// Based on article @
// Publish a factory method for Chart instances
// @usage:
// var runningChart = BarChart.instanceOf( {barPadding : 2 } );
// var weatherChart = BarChart.instanceOf()
// .fillColor('coral');
window.BarChart = {
View angular-in-view-directives.html
<!-- wInViewRoot directive is needed to specify the `root` for `IntersectionObserver` and some other it's options e.g. `margin` -->
<div class="container" wInViewRoot="viewport">
Any content can be here
<!-- Content will be replaced by a placeholder <div> with the same height as original content.
Also `InViewItemComponent`s change detector will be detached when it become invisible which means
all the content's change detectors won't be reachable and will be inactive as well. -->
...or any other content can be here
ThomasBurleson / log.operator.ts
Last active January 11, 2019 14:04
Using custom RxJS log() operator
View log.operator.ts
export function log(task: string) {
const announceCompleted = () => {
console.log(`${task} %ccomplete`, 'color: green');
return function<T>(source: Observable<T>) {
return source.pipe(
ThomasBurleson / gist:941711
Created April 26, 2011 02:52
Supplant for AS3 [no more StringUtils.substitute]
View gist:941711
package utils.string
* Replaces all tokenized fields in target with field values from
* the fields datasource. With this routine, the mx StringUtils.substitute
* is no longer needed to achieve printf() functionality.
* Supplant is more powerful since it can resolve (on-demand) property chains
* when used as fields; e.g. (as shown below).
ThomasBurleson / switchMap_example.ts
Last active December 13, 2018 19:04
Compare switchMap() to nested subscribe calls.
View switchMap_example.ts
import {Component, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {ContactsService} from '../contacts.service';
import {Contact} from '../models/contact';
import 'rxjs/add/operator/switchMap';
import {Subscription} from 'rxjs';
selector: 'trm-contacts-detail',