Skip to content

Instantly share code, notes, and snippets.

View sasxa's full-sized avatar

Aleksandar Milošević sasxa

View GitHub Profile
@sasxa
sasxa / fi_first_names.txt
Last active August 2, 2022 11:16
Finnish Names
Juhani 282678
Olavi 141290
Antero 136208
Tapani 135416
Johannes 133593
Tapio 114754
Mikael 105062
Kalevi 92595
Matti 78661
Pekka 77433
@sasxa
sasxa / loader.directive.ts
Created July 28, 2017 14:10
LoaderDirective
import {
ComponentFactoryResolver,
Directive,
Input,
OnInit,
Output,
ViewContainerRef,
ComponentRef,
EventEmitter
} from '@angular/core';
@sasxa
sasxa / app-routing.module.ts
Created October 16, 2016 13:17
Nested lazy loaded routes
export const routes: Routes = [
{
path: '',
component: AppComponent,
children: [
{ path: 'home', component: DummyComponent },
{ path: '', canLoad: [AuthGuard], loadChildren: './viewer/viewer.module#ViewerModule' },
// { path: '_', canLoad: [AuthGuard], loadChildren: './editor/editor.module#EditorModule' },
{ path: '**', redirectTo: 'home' },
@sasxa
sasxa / BaseForm.ts
Last active May 23, 2017 11:55
Angular2 Forms with @ngrx/store
export class _BaseForm {
_builder: FormBuilder;
_group: ControlGroup;
public controls = (value: any = {}) => ({
});
public selector: string = "examples";
public store: Store<any>;
constructor() { }
@sasxa
sasxa / BaseRoute.ts
Last active July 25, 2018 17:23
Angular2 Redirection using @ngrx/store
export class _BaseRoute {
public store: Store<any> = getSingleton(Store);
public title: string;
constructor() { }
routerOnActivate(next: ComponentInstruction, prev: ComponentInstruction) {
this.store.dispatch({ type: "UPDATE_ROUTE", payload: { next, prev } });
this.store.dispatch({ type: "UPDATE_UI", payload: { title: this.title } });
}
@sasxa
sasxa / queue.yaml
Last active October 21, 2016 16:03
Google Cloud Endpoints Authentication (Google App Engine, Python) - getting user profile from Google+
total_storage_limit: 200M
queue:
- name: registration
rate: 20/s
bucket_size: 40
max_concurrent_requests: 10
retry_parameters:
task_age_limit: 10h
min_backoff_seconds: 10
@sasxa
sasxa / karma.conf.js
Last active July 14, 2016 11:28
Setup for karma testing
// Karma configuration
// Generated on Thu Dec 24 2015 20:24:55 GMT+0100 (Central Europe Standard Time)
module.exports = function(config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
@sasxa
sasxa / emitter.service.ts
Created January 2, 2016 05:27
Angular2 Communicating between sibling components
import {Injectable, EventEmitter} from 'angular2/core';
@Injectable()
export class EmitterService {
private static _emitters: { [ID: string]: EventEmitter<any> } = {};
static get(ID: string): EventEmitter<any> {
if (!this._emitters[ID])
this._emitters[ID] = new EventEmitter();
return this._emitters[ID];