Skip to content

Instantly share code, notes, and snippets.

View abner's full-sized avatar

Ábner Silva de Oliveira abner

View GitHub Profile
@abner
abner / BUNDLE_TYPESCRIPT_LIBRARY.md
Created June 10, 2018 18:35
Bundle Typescript Library With Webpack

Writing our library V

We need various formats to support every environment

  • ES5
    • AMD
    • CommonJS
    • UMD
  • ES2015
@abner
abner / mockActivatedRoute.ts
Created June 8, 2018 21:54 — forked from benjamincharity/mockActivatedRoute.ts
Mock ActivatedRoute with params, data and snapshot.
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
MdToolbarModule,
],
providers: [
{
provide: Router,
useClass: MockRouter,
},
@abner
abner / typings-worker.js
Last active June 6, 2018 09:00
typings-worker.js
// This worker resolves typings (.d.ts files) for the given list of dependencies.
self.importScripts([
'https://cdnjs.cloudflare.com/ajax/libs/typescript/2.8.3/typescript.min.js'
]);
//const PACKAGES_SOURCE = 'https://unpkg.com';
const PACKAGES_SOURCE = 'https://cdn.jsdelivr.net/npm'
const resolved = {};
@abner
abner / index.ts
Created May 30, 2018 16:28 — forked from carloslfu/index.ts
Stackblitz resolver with Github support
import { Resolver, NpmHttpRegistry } from '@stackblitz/turbo-resolver';
function resolve(dependencies){
const resolver = new Resolver();
return resolver.resolve(dependencies);
}
resolve({
"rxjs": "https://github.com/reactivex/rxjs", // Master branch of Rx.js repo
"left-pad": "*",
@abner
abner / 1.md
Created May 28, 2018 21:20 — forked from getify/1.md
BetterPromise: a strawman experiment in subclassing Promise and "fixing" a bunch of its awkward/bad parts

Some things that are "better" with this BetterPromise implementation:

  • BetterPromise # unthen(..) / BetterPromise # uncatch(..) / BetterPromise # unfinally(..) allows you to unregister a fulfillment or rejection handler that you previously registered on a promise via then(..) or catch(..), or unregister a resolution handler that you previously registered on a promise via finally(..).

    NOTE: This seems to be the majority use-case for why many like/want "promise cancelation" -- IOW, often what you want is to just stop observing a promise's resolution, not actually forcibly cancel the operation is comes from.

    var p = new BetterPromise(function(res){
       setTimeout(function(){ res(42); },100);
    });
@abner
abner / ViewController.m
Created May 21, 2018 12:54
Objective-C execute Javascript
//
// ViewController.m
// app-with-jscontext
//
// Created by DE505 on 21/05/2018.
// Copyright © 2018 DE505. All rights reserved.
//
#import "ViewController.h"
@abner
abner / form.spec.ts
Created April 22, 2018 10:08
form.spec.ts
// Teste Unitário de FormBuilder
import { Component } from '@angular/core';
import { FormBuilder, FormGroup, Validators, ReactiveFormsModule, FormsModule } from '@angular/forms';
import { async, TestBed } from '@angular/core/testing';
describe('FormBuilder', () => {
/* @Component({
@abner
abner / app.component.ts
Last active April 22, 2018 10:01
AngularPreload
...
ngAfterViewInit() {
document.getElementById('loadingIndicator').style.display = 'none';
}
@abner
abner / .dockerignore
Created April 22, 2018 09:18
Angular,Jest,DockerGVIM
node_modules
@abner
abner / ArrayToSingleResult.java
Last active January 18, 2018 01:46
Java - From Array Observable into a Array mapped from multiple Single operations
import io.vertx.core.json.JsonArray;
import rx.Observable;
import rx.Single;
/**
* @author abner2
*/
public class RxPlayground {
public static void main(String[] args) {