EBIA

Category: Miscellaneous (page 1 of 2)

Miscellaneous

Git-TFS-Error: RPC failed; HTTP 501 curl 22 The requested URL returned error: 501 Not Implemented

Problem

Counting objects: 131, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (43/43), done.
error: RPC failed; HTTP 501 curl 22 The requested URL returned error: 501 Not Implemented
fatal: The remote end hung up unexpectedly
Writing objects: 100% (131/131), 2.26 MiB | 4.87 MiB/s, done.
Total 131 (delta 102), reused 103 (delta 76)
fatal: The remote end hung up unexpectedly
Everything up-to-date

Solution

At first try a garbage collection:

git gc --aggressive

Run this command in root folder of git repository

git config --get http.postBuffer

If it shows nothing, than used default value ( 1 MiB from git config man page )

Now set this value

git config http.postBuffer 524288000

To allow up to the file size 500M

Convert from PFX to CRT/KEY

pkcs12 -in localhost.pfx -clcerts -nokeys -out localhost.crt
pkcs12 -in localhost.pfx -nocerts -nodes -out localhost.key

 

Angular CLI with SSL

in package.json

"scripts": {
    ..
    "https": "ng serve --ssl true --ssl-key \"certs/localhost.key\" --ssl-cert \"certs/localhost.crt\"",
    ..
}

Brew node / npm Problem: Error: Cannot find module ‘semver’

  • sudo rm -rf /usr/local/lib/node_modules
  • sudo rm -rf ~/.npm
  • brew uninstall –force node
  • brew install node

Understanding Scope in TypeScript Array Functions

TypeScript  ↓
let a = {
    foo: 'bar',
    run: function (){
        setTimeout(()=>{
            console.log(this.foo);
        },2000)
    }
};

a.run();
JavaScript  ↓
var a = {
    foo: 'bar',
    run: function () {
        var _this = this;
        setTimeout(function () {
            console.log(_this.foo);
        }, 2000);
    }
};
a.run();

 

Gnomon

A command line utility, a bit like moreutils’s ts, to prepend timestamp information to the standard output of another command. Useful for long-running processes where you’d like a historical record of what’s taking so long.

https://www.npmjs.com/package/gnomon

Observables

Observables vs. Functions

Observables are lazy Push collections of multiple values.

Observables are like functions with zero arguments, but generalize those to allow multiple values. Subscribing to an Observable is analogous to calling a Function. Observables are able to deliver values either synchronously or asynchronously.

What is the difference between an Observable and a function? Observables can “return” multiple values over time, something which functions cannot.

Conclusion:

  • func.call() means “give me one value synchronously
  • observable.subscribe() means “give me any amount of values, either synchronously or asynchronously

Anatomy of an Observable

Observables are created using Rx.Observable.create or a creation operator, are subscribed to with an Observer, execute to deliver next / error / complete notifications to the Observer, and their execution may be disposed.

Observables can be created with create, but usually we use the so-called creation operators, like of, from, interval, etc.

In an Observable Execution, zero to infinite Next notifications may be delivered. If either an Error or Complete notification is delivered, then nothing else can be delivered afterwards.

When you subscribe, you get back a Subscription, which represents the ongoing execution. Just call unsubscribe() to cancel the execution.

Observer

An Observer is a consumer of values delivered by an Observable. Observers are simply a set of callbacks, one for each type of notification delivered by the Observable: next, error, and complete.

The following is an example of a typical Observer object:

var observer = {
  next: x => console.log('Observer got a next value: ' + x),
  error: err => console.error('Observer got an error: ' + err),
  complete: () => console.log('Observer got a complete notification'),
};

To use the Observer, provide it to the subscribe of an Observable:

observable.subscribe(observer);

Subscription

A Subscription is an object that represents a disposable resource, usually the execution of an Observable. A Subscription has one important method, unsubscribe, that takes no argument and just disposes the resource held by the subscription. In previous versions of RxJS, Subscription was called “Disposable”.

Subscriptions can also be put together, so that a call to an unsubscribe() of one Subscription may unsubscribe multiple Subscriptions. You can do this by “adding” one subscription into another:

var observable1 = ........
var observable2 = ........

var subscription = observable1.subscribe(...
var childSubscription = observable2.subscribe(...

subscription.add(childSubscription);

setTimeout(() => {
  // Unsubscribes BOTH subscription and childSubscription
  subscription.unsubscribe();
}, 1000);

Subscriptions also have a remove(otherSubscription) method, in order to undo the addition of a child Subscription.
>> source

RxJS revisited

>> source

Flow Control Operators

filter, delay, debounceTime, take, takeUntil, distinct, distinctUntilChanged, throttleTime

throttleTime

Allow at most one click per second:

var button = document.querySelector('button');
Rx.Observable.fromEvent(button, 'click')
  .throttleTime(1000)
  .scan(count => count + 1, 0)
  .subscribe(count => console.log(`Clicked ${count} times`));

Value Producing Operators

pluck, pairwise, sample,

Angular Testing Revisited – V4+

Introduction

Setup

ng new ng-testing --routing
npm start
ng test
ng test --code-coverage
Olderposts

Copyright © 2020 EBIA

Theme by Anders NorenUp ↑