Skip to content

Instantly share code, notes, and snippets.

View benjamincharity's full-sized avatar
🤖

Benjamin Charity benjamincharity

🤖
View GitHub Profile
@benjamincharity
benjamincharity / 1.0.1-output.sh
Last active November 1, 2017 15:19
Docs working on `1.0.1`, not working on `1.0.2`
➜ my-app git:(fix-link-style-inheritence) ✗ yr docs
yarn run v1.2.1
$ yarn run docs:toc
DocToccing single file "./README.md" for github.com.
==================
"./README.md" will be updated
@benjamincharity
benjamincharity / WindowService.ts
Created August 28, 2017 19:30
A window service that exposes the native window object AND the width/height of the window as an Observable.
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/operator/pluck';
import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/observable/fromEvent';
export interface WindowSize {
@benjamincharity
benjamincharity / CreateGuid.ts
Created August 10, 2017 12:15
A TypeScript class that generates a guid
// http://stackoverflow.com/questions/26501688/a-typescript-guid-class
class Guid {
static newGuid() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
const r = Math.random() * 16 | 0, v = c === 'x' ? r : ( r & 0x3 | 0x8 );
return v.toString(16);
});
}
}
@benjamincharity
benjamincharity / linesperauthor.gitconfig
Created August 9, 2017 16:41
Git alias function to show how many lines were authored by each contributor.
[alias]
linesperauthor = "!f() { \
git ls-files | while read f; do git blame --line-porcelain $f | grep '^author '; done | sort -f | uniq -ic | sort -n; \
}; f"
# usage:
# git linesperauthor
# output:
@benjamincharity
benjamincharity / deletebranch.gitconfig
Last active May 10, 2023 14:39
Git alias function to delete local AND remote branch(s). NOTE: If dealing with branches that are not fully merged, the `-d` would need to change to `-D`.
[alias]
deletebranch = "!f() { \
git push origin --delete "$@"; \
git branch -d "$@"; \
}; f"
# usage:
# git deletebranch my-branch
# git deletebranch branch-1 branch-2 branch-3
@benjamincharity
benjamincharity / theme-base.component.ts
Created August 7, 2017 15:30
Create a base class that will set a theme class on the component.
import {
Component,
Input,
ElementRef,
} from '@angular/core';
import { TsStyleThemeTypes } from './../types/style-theme.types';
/**
@benjamincharity
benjamincharity / compodoc-files.txt
Created August 7, 2017 14:49
List of files collected before compodoc `RangeError: Maximum call stack size exceeded` error.
/Users/bc/code/Terminus/terminus-ui/src/lib/index.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/button/button.component.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/button/button.module.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/checkbox/checkbox.component.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/checkbox/checkbox.module.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/copy/copy.component.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/copy/copy.module.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/date-range/date-range.component.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/date-range/date-range.module.ts,
/Users/bc/code/Terminus/terminus-ui/src/lib/src/datepicker/datepicker.component.ts,
@benjamincharity
benjamincharity / button.component.ts
Last active July 31, 2017 15:48
A method for theming components based off a set list of themes.
import {
Component,
Input,
Output,
EventEmitter,
ElementRef,
} from '@angular/core';
import { ButtonActionTypes } from './../types/button-action.types';
import { ButtonFunctionTypes } from './../types/button-function.types';
@benjamincharity
benjamincharity / orderArrayByProperty.ts
Created July 27, 2017 18:36
Order an array of objects by a top-level property value.
/**
* Order an array alphabetically by property
*
* @param {Array} items The array of objects to sort
* @param {String} property The property to sort by
* @param {Boolean} isDescending A flag determining if the array should be sorted ascending or
* descending
* @return {Array} sortedArray The sorted array
*/
export default function orderArrayByProperty(items: any[], property: string, isDescending: boolean = true): any[] {
@benjamincharity
benjamincharity / spacing.scss
Last active July 27, 2017 12:47
Create utility classes to enforce vertical spacing
@import './typography';
/**
* The vertical spacing default
*
* @nuclide vertical-spacing
* @section Config > Spacing
*/
$g-spacing: $type__size--base !default;