Skip to content

Instantly share code, notes, and snippets.

View jschwarty's full-sized avatar

Justin Schwartzenberger jschwarty

View GitHub Profile
@jschwarty
jschwarty / settings.json
Last active June 7, 2024 20:20
VSCode setting to set ./node_modules/.bin into PATH on new terminal window open
"terminal.integrated.env.osx": {
"PATH": "./node_modules/.bin:${env:PATH}"
},
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "zsh",
"args": ["-i"]
}
},
@jschwarty
jschwarty / ng-let.directive.ts
Last active June 30, 2020 14:41
Angular ngLet directive
// From https://stackblitz.com/edit/directive-collection-with-examples?file=src%2Fapp%2Fng-let.directive.ts
import {
Directive,
Input,
TemplateRef,
ViewContainerRef,
EmbeddedViewRef
} from "@angular/core";
@Directive({
@jschwarty
jschwarty / .zshrc
Last active October 25, 2019 01:35
oh-my-zsh .zshrc customization
ZSH_THEME="agnoster"
plugins=(git nvm)
prompt_context() {}
prompt_dir() {
prompt_segment blue $CURRENT_FG '%1~'
}
@jschwarty
jschwarty / git.zsh
Last active October 12, 2019 17:22
Custom functions for oh-my-zsh terminal to work with common git stuff
# Sync master with remote upstream (and re-checkout previous branch)
function gitsum {
currentBranch=$(git symbolic-ref -q --short HEAD)
git fetch upstream
git checkout master
git merge upstream/master
git push
git checkout $currentBranch
}
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
class NgxLetContext {
ngxLet: any;
}
/*
* Example usage
* <ng-container *ngxLet="person$ | async as person">
* <h1>{{person.name}}</h1>
describe('doit', () => {
it('should build graph', () => {
const t = {
cart: ['saved'],
saved: ['items'],
items: []
};
const r = {
cart: 'cart',
import { ActivatedRouteSnapshot } from '@angular/router';
export function getFullTreeParams(route: ActivatedRouteSnapshot, params = {}) {
if (route) {
params = {...params, ...route.params};
}
return route.firstChild
? this.getFullTreeParams(route.firstChild, params)
: params;
}
@jschwarty
jschwarty / getFullTreeParams.ts
Created March 9, 2018 19:24
Recursive function for getting route params from the Angular router snapshot
import { ActivatedRoute } from '@angular/router';
export function getFullTreeParams(route: ActivatedRoute, params = {}) {
if (route) {
params = {...params, ...route.snapshot.params};
}
return route.parent
? this.getFullTreeParams(route.parent, params)
: params;
}
@jschwarty
jschwarty / imports.ts
Created November 11, 2017 01:12
Blog Post (Nrwl) - nx modularize 2
// Add this one to an AppModule imports
import { BackendProviderModule } from '@myproject/backend-provider';
// Use this one in the AppComponent for constructor injection
import { BackendService } from '@myproject/backend-provider';
@jschwarty
jschwarty / index.ts
Last active November 11, 2017 01:10
Blog Post (Nrwl) - nx modularize code 1
// Only exported types will be able to be imported elsewhere
export { BackendProviderModule } from './src/backend-provider.module';
export { BackendService } from './src/backend.service';
// leave out the private stuff, like that Helpers class