Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
👨🏻‍🍳 helping you cook better apps

Younes Jaaidi yjaaidi

💭
👨🏻‍🍳 helping you cook better apps
View GitHub Profile
View reactive-store.ts
import { ReplaySubject } from 'rxjs/ReplaySubject';
import { Observable } from 'rxjs/Observable';
export abstract class ReplayStore<T> {
private _isInitialized = false;
private _state: T;
private _state$: ReplaySubject<T>;
constructor() {
@yjaaidi
yjaaidi / generate-cert.sh
Created Jul 10, 2017
Generate dev self-signed certificate
View generate-cert.sh
#!/usr/bin/env bash
# Generate private key and CSR.
openssl req -nodes -newkey rsa:2048 -keyout ssl/server.key -out ssl/server.csr -subj "//CN=devserver"
# Auto-signing.
#openssl req -x509 -sha256 -days 365 -key ssl/server.key -in ssl/server.csr -out ssl/server.pem
openssl x509 -req -days 365 -in ssl/server.csr -signkey ssl/server.key -out ssl/server.crt
# Removing CSR.
View rest-api-workflow.py
// Create an order.
POST /orders
request = {
title: 'TITLE',
description: 'DESCRIPTION'
}
response = {
id: 'ORDER_ID',
title: 'TITLE',
View angular-async-pipe.ts
import { Component } from '@angular/core';
import { interval } from 'rxjs';
@Component({
template: `<div>{{ count$ | async }}</div>`
})
export class CounterComponent {
count$ = interval(1000);
View angular-manual-unsubscribe.ts
import { Component } from '@angular/core';
import { Subscription, interval } from 'rxjs';
@Component({
template: `<div>{{ count }}</div>`
})
export class CounterComponent implements OnDestroy, OnInit {
count: number;
View angular-async-pipe-and-share-replay.ts
import { Component } from '@angular/core';
import { interval } from 'rxjs';
import { shareReplay } from 'rxjs/operators';
@Component({
template: `
<div>{{ count$ | async }}</div>
<div>{{ count$ | async }}</div>
`
})
View angular-take-until-destroyed.ts
import { Component, OnDestroy, OnInit } from '@angular/core';
import { Subject, interval } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
@Component({
template: `
<div>{{ count }}</div>
<button (click)="startCounting()">Start Counting</button>
`
})
View angular-rx-scavenger.ts
import { Component, OnInit } from '@angular/core';
import { Scavenger } from '@wishtack/rx-scavenger';
import { interval } from 'rxjs';
@Component({
template: `<div>{{ count }}</div>`
})
export class CounterComponent implements OnDestroy, OnInit {
count: number;
View angular-rx-scavenger-collect-by-key.ts
import { Component, OnInit } from '@angular/core';
import { Scavenger } from '@wishtack/rx-scavenger';
import { interval } from 'rxjs';
@Component({
template: `<div>{{ count }}</div>`
})
export class CounterComponent implements OnDestroy, OnInit {
count: number;
View angular-picture-require.ts
@Component({
selector: 'wt-logo',
template: `<img [src]="logoUrl">`
})
export LogoComponent {
logoUrl = require('!!url-loader!./logo.svg');
}