Skip to content

Instantly share code, notes, and snippets.

@gund
gund / index.html
Last active February 12, 2024 00:06
ArcGIS JSAPI setup build with Webpack for production (start reading from webpack.config.js)
<!DOCTYPE html>
<html>
<head>...</head>
<body>
<!-- Load Esri lib -->
<link rel="stylesheet" href="//js.arcgis.com/4.0/esri/css/main.css">
<script src="//js.arcgis.com/4.0/"></script>
<!-- Load our AMD app -->
<script type="text/javascript">
// Wrap our app startup in AMD module
@gund
gund / http-interceptor-concept.md
Last active September 19, 2022 01:08
Concept of Http Interceptor for Angular 2

First, we need to define interfaces with which we will work:

export interface Interceptable<T extends Interceptor<any, any>> {
  addInterceptor(interceptor: T): Interceptable<T>;
  removeInterceptor(interceptor: T): Interceptable<T>;
  clearInterceptors(interceptors?: T[]): Interceptable<T>;
}

export interface Interceptor<T, D> {
@gund
gund / readme.md
Last active July 4, 2018 18:27
Webpack 2 beta circular dependencies trouble

So consider we have Logger class. And also we have a LoggerInContext class which extends Logger. And Logger has factory method to create new LoggerInContext instances.

// logger.ts

import { LoggerInContext } from './logger-in-context';

export class Logger {
@gund
gund / CLA Agreement.md
Last active April 10, 2017 07:21
CLA Agreement

SAP Individual Contributor License Agreement

Thank you for your interest in contributing to open source software projects (“Projects”) made available by SAP SE or its affiliates (“SAP”). This Individual Contributor License Agreement (“Agreement”) sets out the terms governing any source code, object code, bug fixes, configuration changes, tools, specifications, documentation, data, materials, feedback, information or other works of authorship that you submit or have submitted, in any form and in any manner, to SAP in respect of any of the Projects (collectively “Contributions”). If you have any questions respecting this Agreement, please contact [email protected].

You agree that the following terms apply to all of your past, present and future Contributions. Except for the licenses granted in this Agreement, you retain all of your right, title and interest in and to your Contributions.

Copyright License. You hereby grant, and agree to grant, to SAP a non-exclusive, perpetual, irrevocable, worldwi

@gund
gund / ng-router-resolver.ts
Created June 15, 2017 13:01
Angular Router Static Resolver (draft)
import { NgModule } from '@angular/core';
import * as ts from 'typescript';
const startTime = Date.now();
main()
.then(() => Date.now())
.then(endTime => console.log(`Done in ${endTime - startTime}ms`))
.catch(e => {
console.error(e);
@gund
gund / index.md
Last active June 20, 2017 08:58
Generate routes manifest for @angular/service-worker

This is small script that can help generating routes manifest for @angular/service-worker. It is alternative way for ng-pwa-tools to generate manifest without ever running angular application on the server.

It requires you to have installed ng-pwa-tools and ng-router-resolver libraries.

It is a drop-in replacement for command ngu-sw-manifest.

NOTE: --out argument should point to existing manifest json file.

routes.js:

@gund
gund / rollup.config.js
Last active June 21, 2017 17:48
Rollup Angular configuration
// Precompile angular module before server-side rendering
import typescript from 'rollup-plugin-typescript2';
import angular from 'rollup-plugin-angular';
import nodeResolve from 'rollup-plugin-node-resolve';
import alias from 'rollup-plugin-alias';
import { GLOBAL, globalsRegex } from 'rollup-globals-regex';
export default {
entry: 'src/app/app.module.ts',
dest: 'dist-ngu/app.module.js',
@gund
gund / readme.md
Last active July 28, 2017 12:14
Run angular application in custom zone

This shows how you can customize zone behavior in which Angular App will run.

Can be useful for example if you want to intercept all events that angular dispatches to your handlers.

First, create a custom-zone.ts file:

import 'zone.js';

interface TaskInfo {
  delegate: ZoneDelegate;
@gund
gund / advanced-renderer.md
Last active August 12, 2017 19:24
Example of abstract advanced renderer for Angular to execute arbitrary function on different safe thread (ex. webworker)

Advanced Renderer

The idea here is to have an abstraction to safely run browser dependent code in non browser-native environment (like webworker or server-side) without breaking the app and not changing any application logic code.

execute(expression: string, args?: ExpressionArguments): Promise

import { Injectable, NgModule, PLATFORM_INITIALIZER, Provider } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {
@gund
gund / mask.md
Last active July 29, 2024 12:36
Simple Angular mask directive

Simple Angular mask directive

This directive does not create it's own value accessor - it simply reuses whatever element is using already and just hooks in.

Also it is fully abstracted off of the HTML implementation and so can be safely used in WebWorker and server side environment.

Usage