Skip to content

Instantly share code, notes, and snippets.


Benjamin Charity benjamincharity

View GitHub Profile
View removeByKey.js
removeByKey(array, params) {
array.some(function(item, index) {
if (array[index][params.key] === params.value) {
array.splice(index, 1);
return true;
return false;
return array;
View mockStore.ts
import { Action, Store } from '@ngrx/store';
import { Subject } from 'rxjs/Subject';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
* Standard mockstore that can be used in unittests to mock a @ngrx/store
View rollup-globals.ts
export const rollupGlobals = {
'tslib': 'tslib',
'moment': 'moment',
// lodash
'lodash': 'lodash',
'lodash-es': 'lodash-es',
'lodash-es/at': 'lodash-es/at',
'lodash-es/cloneDeep': 'lodash-es/cloneDeep',
'lodash-es/concat': 'lodash-es/concat',
benjamincharity / app-version.component.ts
Last active Dec 4, 2017
From: It's worth to mentioned that if someone encounter on error "Cannot find name require" after applying your solution then needs to add "node" type inside "types" property in file. << "types": ["node"] >>.
View app-version.component.ts
const { version: appVersion } = require('../../package.json')
// this loads package.json
// then you destructure that object and take out the 'version' property from it
// and finally with ': appVersion' you rename it to const appVersion
selector: 'stack-overflow',
templateUrl: './stack-overflow.component.html'
export class StackOverflowComponent {
View tslint.json
"rulesDirectory": [
"rules": {
"angular-whitespace": [
"arrow-parens": true,
View stylelintrc.json
"rules": {
"at-rule-name-space-after": "always",
"at-rule-semicolon-space-before": "never",
"at-rule-semicolon-newline-after": "always",
"at-rule-no-vendor-prefix": true,
"block-no-empty": true,
"block-closing-brace-newline-after": [
"ignoreAtRules": [
yarn remove karma-sauce-launcher
yarn add -D --exact karma-sauce-launcher
benjamincharity /
Last active Nov 1, 2017
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 "./" for
"./" will be updated
benjamincharity / WindowService.ts
Created Aug 28, 2017
A window service that exposes the native window object AND the width/height of the window as an Observable.
View WindowService.ts
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 {
You can’t perform that action at this time.