Skip to content

Instantly share code, notes, and snippets.

View ssougnez's full-sized avatar

Sébastien Sougnez ssougnez

View GitHub Profile
var x = 5;
x = "Hello";
@ssougnez
ssougnez / afzts-03.js
Last active September 23, 2024 06:41
const cowsay = require("cowsay");
console.log(cowsay.say({
text : "From Zero To Somewhere",
e : "oO",
T : "U "
}));
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
@ssougnez
ssougnez / afzts-01.js
Last active September 23, 2024 06:09
console.log('Hello');
<ngs-container [query$]="query$"
[data$]="pokemons$">
<ng-template let-pokemons>
<div *ngFor="let p of pokemons; trackBy: trackByValue">{{ p.name }}</div>
</ng-template>
</ngs-container>
import { NgFor } from '@angular/common';
import { ChangeDetectionStrategy, Component, inject, TrackByFunction } from '@angular/core';
import { NgStore, NgStoreModule, trackByValue } from '@ssougnez/ng-store';
import { map, Observable } from 'rxjs';
import { Pokemon } from './models/pokemon.model';
import { PokemonService } from './services/pokemon.service';
import { AppState } from './state/app.state';
@Component({
selector: 'app-root',
import { inject, Injectable } from "@angular/core";
import { NgStore } from "@ssougnez/ng-store";
import { Observable } from "rxjs";
import { Pokemon } from "../models/pokemon.model";
import { AppState } from "../state/app.state";
@Injectable({
providedIn: 'root'
})
export class PokemonService {
import { createEntities, Entities } from "@ssougnez/ng-store";
import { Pokemon } from "../models/pokemon.model";
export type AppState = {
pokemons: Entities<Pokemon>;
}
export const initial: AppState = {
pokemons: createEntities<Pokemon>([], ['type'])
}
import { BaseEntity } from "@ssougnez/ng-store";
export type Pokemon = BaseEntity<number> & {
name: string;
type: 'water' | 'fire' | 'electric' | 'grass' | 'bug' | 'normal' | 'poison';
}
if (element.tagName === 'A') {
const href: string = element.href?.toLowerCase();
if (href?.startsWith(location.origin.toLowerCase())) {
element.addEventListener('click', (e: MouseEvent) => {
this._router.navigate([href.substring(location.origin.length)]);
e.preventDefault();
});
}
}