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 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-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-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-picture-require.ts
@Component({
selector: 'wt-logo',
template: `<img [src]="logoUrl">`
})
export LogoComponent {
logoUrl = require('!!url-loader!./logo.svg');
}
View angular-logo-selector.ts
@Component({
selector: 'wt-logo',
template: `
<img [src]="getLogoUrl()">
<button (click)="company = 'wishtack'">WISHTACK</button>
<button (click)="company = 'google'">GOOGLE</button>
`
})
export class LogoComponent {
@yjaaidi
yjaaidi / splunk-user-agent-stats
Last active Jun 21, 2018
Splunk user-agent statistics
View splunk-user-agent-stats
| search *
| lookup user_agents http_user_agent as user_agent
| replace "unknown" with "" in ua_device, ua_os_major, ua_os_minor
| replace "Windows*" with "Windows" in ua_os_family
| eval user_agent=ua_os_family + " - " + ua_family
| regex user_agent!="(unknown|PhantomJS)"
| eventstats dc(address) as total
| stats dc(address) as count by user_agent, total
| eval percentage=(count * 100/total)
| table percentage user_agent
@yjaaidi
yjaaidi / speech-recognition-playground.js
Last active Oct 11, 2018
Speech Recognition Playground
View speech-recognition-playground.js
recognition = new webkitSpeechRecognition();
recognition.continuous = true;
recognition.lang = 'fr-FR';
recognition.onresult = console.log;
recognition.start();