Skip to content

Instantly share code, notes, and snippets.

@aegyed91
aegyed91 / ngrxintro.md
Last active April 18, 2016 12:12 — forked from btroncone/ngrxintro.md
A Comprehensive Introduction to @ngrx/store - Companion to Egghead.io Series
function person(state, action) {
state = state || {};
switch(action.type){
case 'ADD_INFO':
return Object.assign({}, state, action.payload);
default:
return state;
}
}
@aegyed91
aegyed91 / server.js
Created May 13, 2016 10:16
hapi server method promise bug reproduction
var Hapi = require('hapi');
const server = new Hapi.Server({
cache: [
{
name: 'redisCache',
engine: require('catbox-redis'),
host: '127.0.0.1',
partition: 'cache'
}
@aegyed91
aegyed91 / alert.js
Last active February 10, 2017 10:58
Angular 2 dynamic component creation
import { Component, Directive, TemplateRef, ViewContainerRef, Injector,
ComponentFactoryResolver, Renderer } from '@angular/core';
@Component({
selector: 'alert',
template: `
<div class="alert alert-success" role="alert">
<ng-content></ng-content>
</div>
`
@aegyed91
aegyed91 / ripple.css
Created August 7, 2016 20:26
ng2 ripple effect directive
/* https://codepen.io/Craigtut/pen/dIfzv */
.ripple {
overflow: hidden;
}
.ripple-effect {
position: absolute;
border-radius: 50%;
width: 50px;
height: 50px;
@aegyed91
aegyed91 / form-group.c.html
Created November 30, 2016 14:01
address google api places typeahead angular 2 formgroup integrated hax thing
<div class="form-group" [ngClass]="{'has-danger': feedback && !state.valid && !state.control.pristine }">
<label *ngIf="label" class="form-control-label">{{label}}</label>
<ng-content></ng-content>
<div *ngIf="feedback && !state.valid && !state.pristine">
<div *ngIf="state.hasError('required')" class="form-control-feedback">Required field.</div>
<div *ngIf="state.hasError('minlength')" class="form-control-feedback">Has to be at least {{state.getError('minlength').requiredLength}} characters long.</div>
<div *ngIf="state.hasError('maxlength')" class="form-control-feedback">Has to be less than {{state.getError('maxlength').requiredLength}} characters long.</div>
<div *ngIf="state.hasError('incorrectFileExtension')" class="form-control-feedback">File extension has to be <code>{{state.getError('incorrectFileExtension').requiredFileExtension}}</code>.</div>
@aegyed91
aegyed91 / auth.g.ts
Last active December 13, 2016 10:01
rxjs good or not :f
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { CanActivate, CanActivateChild, ActivatedRouteSnapshot } from '@angular/router';
import { AuthS } from '../../routes/auth/auth.s';
import { UserSt } from '../../routes/user/user.st';
import { isEmpty } from 'lodash';
@Injectable()
export class LoggedInG implements CanActivate/*, CanActivateChild*/ {
@aegyed91
aegyed91 / app.m.ts
Last active December 14, 2016 13:05
extend JwtHttp
// Imports
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { SharedModule } from './shared/modules';
import { AppRoutingM } from './app-routing.m';
import { TranslateModule, TranslateLoader, TranslateStaticLoader } from 'ng2-translate';
// Declarations
import { AppC } from './app.c';
import { errorD } from './routes/error/index';
@aegyed91
aegyed91 / state.s.ts
Created December 15, 2016 16:11
state
import { Injectable } from '@angular/core';
import { BehaviorSubject, Subscription } from 'rxjs';
import { get, set, assign, merge, isEmpty } from 'lodash';
import { IS_DEV } from '../constants';
import { ResMsgHandlerS } from './res-msg-handler.s';
export interface IStateOpts {
initState?: Object;
}
@aegyed91
aegyed91 / email
Created December 19, 2016 13:20
validators
import { ValidatorFn, AbstractControl } from '@angular/forms';
/**
* All file sizes specified in bytes.
*/
export function emailValidator(): ValidatorFn {
return (control: AbstractControl): {[key: string]: any} => {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
const passed = re.test(control.value);