Skip to content

Instantly share code, notes, and snippets.

View bonomiandreia's full-sized avatar
🐆

bonomiandreia

🐆
  • Lisboa, Portugal
View GitHub Profile
@bonomiandreia
bonomiandreia / observables.ts
Created March 25, 2022 02:53
observables and subject study
observables are lazy, means that if it doesnt have a subscribe, observables cant execute the code.
Subject are other type of observable, they both can emit many values.
observables can't emit data outside itself.
subjects can emit multiples values outside itself.
example: https://stackblitz.com/edit/angular-ivy-5tnmap
@bonomiandreia
bonomiandreia / mat-calendar-hover-date.scss
Last active August 16, 2022 10:18
scss example to change / override dates hover to mat-calendar angular material
@media(hover: hover) {
::ng-deep .mat-calendar-body-cell:not(.mat-calendar-body-disabled):hover>.mat-calendar-body-cell-content:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical) {
background-color: red !important;
border-radius: 0 !important;
}
::ng-deep .mat-calendar-body-today:not(.mat-calendar-body-selected):not(.mat-calendar-body-comparison-identical) {
background-color: green !important;
border: 0 !important;
border-radius: 0 !important;
@bonomiandreia
bonomiandreia / angularsignals.js
Last active March 13, 2023 22:22
angular signals
Signals are a value that can be observed, I can call a method in the last item of an array, example. as rxjs, they can work like "follow" updates in variables, objects etc.
.set: set a new value for a variable and notify dependents.
.update: update a value based with a current value (number ) => number + 1 and return the new value
.mutate: catch the new value and updated it. its similar with update, the diference is .mutate doesn't return a value and mentains a history.
effect and computed: will receive a notify and do something about it
effect(() => console.log(we have ${number} dogs now!
function countMinimumOperations(password) {
let operations = 0;
let vowels = 0;
let consonants = 0;
// Count the number of vowels and consonants in the password
for (let i = 0; i < password.length; i++) {
const char = password[i];
if ('aeiou'.includes(char)) {
vowels++;
@bonomiandreia
bonomiandreia / test.ts
Last active October 3, 2024 22:11
bidimensionalarray.ts
interface Employee {
name: string;
role: string;
}
const list: Employee[] = [
{ name: 'andreia', role: 'developer' },
{ name: 'john', role: 'CEO' },
{ name: 'mica', role: 'sales' },
{ name: 'joana', role: 'cleaner' },
function removeTodo(todoList: Todo[], id: number): Todo[] {
throwErrors(todoList, id);
let newList = todoList.filter((item: Todo) => {
return item.id !== id
})
return newList;
}
function toogleTodo(todoList: Todo[], id: number): Todo[] {