Skip to content

Instantly share code, notes, and snippets.

View bonomiandreia's full-sized avatar
🐆

bonomiandreia

🐆
  • Lisboa, Portugal
View GitHub Profile
@bonomiandreia
bonomiandreia / cpf_validator_asterisk_regex.txt
Last active December 14, 2021 22:16
[REGEX] - CPF with asterisk or numbers
/[0-9]{3}\.[\d*]{3}\.[\d*]{3}[-]?[0-9]{2}/
455.423.333-24 // 455.***.***-24
@bonomiandreia
bonomiandreia / mostcommonword.ts
Created February 3, 2022 01:15
most common word in a string with banned word
function mostCommonWord(paragraph: string, bannedWords?: string[]): string {
let invalid = new Set(["!","?","'",",",";","."," "]);
let banned = new Set(bannedWords);
// set can be a type of a array
let words = new Map();
// map should return values and use set to config new values
let buffer = ""
let result = "";
for(let ptr = 0; ptr < paragraph.length; ptr++) {
console.log('-- types: undefined, boolean, number, string, object --');
console.log(typeof undefined); // undefined
console.log(typeof null); // object
console.log(typeof NaN); // number
console.log(typeof false); // boolean
console.log(typeof 0); // number
console.log(typeof ""); // string
console.log(typeof []); // object
console.log(typeof {}); // object
@bonomiandreia
bonomiandreia / usertest.ts
Last active March 8, 2022 13:58
add a line to a object
interface User {
id: number,
name: string,
[key: string]: unknown,
}
const usertype = {
id: 1,
name: 'andreia'
}
@bonomiandreia
bonomiandreia / promisestest.js
Last active March 8, 2022 17:55
promises test
// difference beetween race and all
// ALL
const promise1 = new Promise((resolve, reject) => {
setTimeout(() => {
resolve('promise1 resolved! timeout')
}, 2000)
})
@bonomiandreia
bonomiandreia / inputAndOutput.ts
Created March 21, 2022 15:11
input and output test!
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<app-value-provider (typedValue)="recivedValue($event)"></app-value-provider>
<app-value-receiver *ngIf="valueOfInput" [printValue]="valueOfInput"></app-value-receiver>
`,
})
export class AppComponent implements OnChanges {
@bonomiandreia
bonomiandreia / ngModel.ts
Created March 23, 2022 00:41
study of ngModel
<input type=text [value]="received some value"/>
<input type=text (keyUp)="emit some value"/>
<input type=text [(value)]="emit and received some value (update template "html" and component (ts file)"/>
@bonomiandreia
bonomiandreia / decorators.ts
Last active March 24, 2022 03:29
decorators
@Injector // it says to angular that this service or class can be use without a parameter,
automatize without parameter of constructor
example:
class ServiceOrOtherClass {
constructor(http: httpClient) {
}
}
Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter
ngFor, ngIf says instructs for template what to do
I have a list, so ngFor, loop this array and show the list
I have this variable, if true, ngIf, show this variable
// sass can use directly inside @component
styles: [$font-size: 40em]
ng build doesnt need anymore of --prod flag
remove IE11 suppport to IE11
// angular 13