Skip to content

Instantly share code, notes, and snippets.

View vespertilian's full-sized avatar

Cameron vespertilian

View GitHub Profile
@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
@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 / 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 / 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.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 / 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 / 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 / communications.component.ts
Created November 14, 2016 15:05
ngrx compose for selecting slices of the store
import { Component, OnInit } from '@angular/core';
import {Store, State} from "@ngrx/store";
import {EmailTemplateState} from "./shared/email-template/ngrx/reducer.email-template";
import {EmailTemplate} from "./shared/email-template/model.email-template";
import {compose} from "@ngrx/core";
import {Observable} from "rxjs";
let styles = require('./communications.sass');
@Component({
selector: 'communications',
template: require('./communications.component.jade'),
@vespertilian
vespertilian / communications.component.ts
Created November 14, 2016 15:05
ngrx compose for selecting slices of the store
import { Component, OnInit } from '@angular/core';
import {Store, State} from "@ngrx/store";
import {EmailTemplateState} from "./shared/email-template/ngrx/reducer.email-template";
import {EmailTemplate} from "./shared/email-template/model.email-template";
import {compose} from "@ngrx/core";
import {Observable} from "rxjs";
let styles = require('./communications.sass');
@Component({
selector: 'communications',
template: require('./communications.component.jade'),
@vespertilian
vespertilian / dateFilter.ts
Created September 15, 2016 10:12
Date filter in Angular 1.2 using angular 2 style inputs (one way) and outputs (events).
let templateUrl: string = require('./date-filter.jade');
require('./date-filters.sass');
// note: to call the on change values you must match this call signature
// on-validation-change='vm.validationChange(valid)',
// on-date-change='vm.dateChange({toDate: toDate, fromDate: fromDate})',
export function dateFilter(): ng.IDirective {
return {
restrict: 'A',