Skip to content

Instantly share code, notes, and snippets.

/*
* Generate a firebase push ID
===========================
* Same code used by the Firebase Web SDK (with minor modifications) except the timestamp used
* is not corrected to account for a possible offset between the client's and server's clocks.
*/
var genPushId = function () {
var prevTime = 0
var randChars = [];
@jsayol
jsayol / keybase.md
Created October 23, 2016 06:33
Keybase proof for my GitHub account

Keybase proof

I hereby claim:

  • I am jsayol on github.
  • I am jsayol (https://keybase.io/jsayol) on keybase.
  • I have a public key ASAhefrs89AKPH9_7oqaGlObjj0S-n5cHuuYu2AFPm7vPAo

To claim this, I am signing this object:

@jsayol
jsayol / ng_for_in---same_as_for_of.ts
Last active December 25, 2016 17:27
Monkey patching Angular's ngFor to allow "let item in items" instead of "let items of items"
/*
* This directive simply allows to use "let item in items" instead of "let item of items"
* with ngFor. Its functionality remains unchanged (that is, it still loops over the iterable's values)
*
* To use it just import it into your module and add it to its "declarations".
*/
import {
Directive, TemplateRef, Input, ChangeDetectorRef, ViewContainerRef,
IterableDiffers, OnChanges, SimpleChanges
@Directive({
selector: '[ngFor][ngForIn]'
})
export class NgForIn extends NgFor implements OnChanges {
@Input() ngForIn: any;
constructor(viewContainer: ViewContainerRef,
template: TemplateRef<NgForRow>,
differs: IterableDiffers,
ngOnChanges(changes: SimpleChanges): void {
if ('ngForIn' in changes) {
this.ngForOf = Object.keys(this.ngForIn);
const currentValue: any[] = Object.keys(changes['ngForIn'].currentValue);
const previousValue: any[] = Object.keys(changes['ngForIn'].previousValue);
changes['ngForOf'] = new SimpleChange(previousValue, currentValue);
super.ngOnChanges(changes);
}
import {
Directive, TemplateRef, Input, ChangeDetectorRef, ViewContainerRef,
IterableDiffers, OnChanges, SimpleChanges, SimpleChange
} from '@angular/core';
import { NgFor } from "@angular/common";
import { NgForRow } from "@angular/common/src/directives/ng_for";
@Directive({
selector: '[ngFor][ngForIn]'
})