Skip to content

Instantly share code, notes, and snippets.

View vespertilian's full-sized avatar

Cameron vespertilian

View GitHub Profile
@vespertilian
vespertilian / Pug Webstorm config Arguments
Created January 31, 2017 11:56
Angular2 Pug HTML Doctype Webstorm
// Tools
// File Watchers
// Pug/Jade
// Watcher Settings - Arguments
$FileName$ -O ""{'doctype':'html'}""
@vespertilian
vespertilian / conditional_effects.ts
Created February 9, 2017 04:09
Two options for conditional ngrx effects
@Effect()
selectAndLoadStore$: Observable<Action> = this.actions$
.ofType(storeActions.SELECT_AND_LOAD_STORE)
.withLatestFrom(this.store.select(ngrx.storeState))
.map(([action, storeState]) => [action.payload, storeState])
.switchMap(([storeName, storeState]) => {
const existsInStore = Boolean(storeState.urlNameMap[storeName]);
return Observable.if(
() => existsInStore,
Observable.of(new storeActions.SetSelectedStore(storeName)),
@vespertilian
vespertilian / angular.errors.ts
Created May 9, 2017 11:59
Handling angular errors
import { Response, ResponseOptions } from '@angular/http';
class ErrorResponse extends Response implements Error {
name: any;
message: any;
}
export function mockError(errorResponseOpts: any) {
return new ErrorResponse(new ResponseOptions(errorResponseOpts));
};
@vespertilian
vespertilian / graphql-ratel.md
Last active June 4, 2018 10:16
DGraph useful search snippets

GraphQL+- ratel

Query

View Schema

schema {
  type
  index
 reverse
@vespertilian
vespertilian / angular-sample.ts
Created October 8, 2020 04:26
Use an on destroy service provider instead of creating a subject and destroying it for every component
// Service
@Injectable()
export class OnDestroyService implements OnDestroy {
triggered$ = new Subject()
ngOnDestroy() {
this.triggered$.next()
this.triggered$.complete()
}
@vespertilian
vespertilian / settings.json
Last active September 14, 2023 04:15
VS Code user settings.json
{
"security.workspace.trust.untrustedFiles": "open",
"json.maxItemsComputed": 100000,
"git.openRepositoryInParentFolders": "never",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[typescript]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
@vespertilian
vespertilian / .ideavimrc
Created December 13, 2023 04:35
.ideavimrc
" Show a few lines of context around the cursor. Note that this makes the
" text scroll if you mouse-click near the start or end of the window.
set scrolloff=5
" Do incremental searching.
set incsearch
" Don't use Ex mode, use Q for formatting.
map Q gq