Skip to content

Instantly share code, notes, and snippets.

View NyaGarcia's full-sized avatar
🐈

Nya NyaGarcia

🐈
View GitHub Profile
@NyaGarcia
NyaGarcia / recursive-euclides.ts
Created January 13, 2024 16:46
Recursive Euclidean algorithm to calculate Greatest Common Divisor
function calculateGreatestCommonDivisor(a: bigint, b: bigint) {
if(b === 0n) {
return a;
}
return calculateGreatestCommonDivisor(b, a % b);
}
@NyaGarcia
NyaGarcia / keybindings.json
Created March 31, 2022 10:59
Adding scss support
{
"key": "ctrl+s",
"command": "extension.multiCommand.execute",
"args": {
"sequence": ["postcssSorting.execute", "workbench.action.files.save"]
},
"when": "editorLangId == css || editorLangId == scss"
},
{
"key": "ctrl+meta+s",
@NyaGarcia
NyaGarcia / app-routing.module.ts
Created July 10, 2023 12:02
Configuring the router to automatically bind router state information to component inputs
import { RouterModule, Routes, provideRouter, withComponentInputBinding } from '@angular/router';
import { NgModule } from '@angular/core';
import { PokemonListComponent } from './pokemon-list/pokemon-list.component';
const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: 'pokemon' },
{ path: 'pokemon', component: PokemonListComponent },
];
@NyaGarcia
NyaGarcia / pokemon-list.component.ts
Last active July 10, 2023 11:53
NgBytes Standalone Pokemon List
import { Component, OnInit } from '@angular/core';
import { Pokemon, PokemonService } from '../pokemon.service';
import { CommonModule } from '@angular/common';
import { PokemonCardComponent } from '../pokemon-card/pokemon-card.component';
import { Router } from '@angular/router';
@Component({
selector: 'ngbytes-pokemon-list',
standalone: true,
@NyaGarcia
NyaGarcia / pokemon.service.ts
Last active July 10, 2023 11:36
Ngbytes Standalone Pokemon Service
import { Injectable } from '@angular/core';
export interface Pokemon {
id: string;
name: string;
type: string;
imageUrl: string;
description: string;
defense: number;
attack: number;
@NyaGarcia
NyaGarcia / app-routing.module.ts
Last active July 10, 2023 11:25
NgBytes Standalone App Routing Module
import { RouterModule, Routes, provideRouter, withComponentInputBinding } from '@angular/router';
import { NgModule } from '@angular/core';
import { PokemonListComponent } from './pokemon-list/pokemon-list.component';
const routes: Routes = [
{ path: '', pathMatch: 'full', redirectTo: 'pokemon' },
{
path: 'pokemon',
component: PokemonListComponent,
@NyaGarcia
NyaGarcia / pokemon-detail.component.ts
Last active July 10, 2023 11:23
NgBytes Standalone Pokemon Detail
import { RouterModule } from '@angular/router';
import { Component, OnInit } from '@angular/core';
import { Pokemon, PokemonService } from '../pokemon.service';
import { CommonModule } from '@angular/common';
import { MatButtonModule } from '@angular/material/button';
@Component({
selector: 'app-pokemon-detail',
standalone: true,
@NyaGarcia
NyaGarcia / pokemon-detail.component.html
Last active July 3, 2023 12:41
NgBytes Standalone Pokemon Detail
<div class="detail">
<h2>{{ pokemon.name }}</h2>
<h4>{{ pokemon.type }} type</h4>
<div class="content">
<img [src]="pokemon.imageUrl" alt="Photo of a Pokemon" />
<div>
<p>Attack: {{ pokemon.attack }}</p>
<p>Defense: {{ pokemon.defense }}</p>
<p>
{{ pokemon.description }}
@NyaGarcia
NyaGarcia / pokemon-detail.component.css
Last active April 25, 2023 12:18
NgBytes Standalone Pokemon Detail
h2 {
margin-bottom: 10px;
}
h4 {
color: rgba(0,0,0,.54);
font-weight: normal;
margin-top: 0;
}
@NyaGarcia
NyaGarcia / pokemon-list.component.html
Last active April 24, 2023 17:31
NgBytes Standalone Pokemon List
<div class="card-container">
<ngbytes-pokemon-card
*ngFor="let pokemon of pokemonList"
[pokemon]="pokemon"
(click)="openDetailsPage(pokemon.id)"
></ngbytes-pokemon-card>
</div>