Skip to content

Instantly share code, notes, and snippets.

@roman-bgonz
roman-bgonz / javascript-remove-accents.js
Created November 19, 2021 14:32 — forked from marcelo-ribeiro/javascript-remove-accents.js
An Javascript function to remove accents and others characters from an input string.
// Example: https://codepen.io/marcelo-ribeiro/pen/OJmVOyW
const accentsMap = new Map([
["A", "Á|À|Ã|Â|Ä"],
["a", "á|à|ã|â|ä"],
["E", "É|È|Ê|Ë"],
["e", "é|è|ê|ë"],
["I", "Í|Ì|Î|Ï"],
["i", "í|ì|î|ï"],
["O", "Ó|Ò|Ô|Õ|Ö"],
@roman-bgonz
roman-bgonz / add.sh
Created February 1, 2022 18:49 — forked from gparlakov/add.sh
Add angular apps of a specific version
# these versions are current as of May 18th 2021
# info from https://www.npmjs.com/package/@angular/cli -> Versions
#Angular 2: looks like this is the last RC version before switching to angular 4
npx -p @angular/[email protected] ng new angular2app
#Angular 4: the last CLI version before Angular 5
npx -p @angular/[email protected] ng new angular4app
#Angular 5: the last CLI version before Angular 6
@roman-bgonz
roman-bgonz / ListUtils.java
Created February 17, 2022 00:31 — forked from mageddo/ListUtils.java
How to make pagination at List in java
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* Reference: https://stackoverflow.com/questions/19688235/how-to-implement-pagination-on-a-list
* @author elvis
* @version $Revision: $<br/>
* $Id: $
@roman-bgonz
roman-bgonz / sonarqube-setup-angular.md
Created April 19, 2022 14:45 — forked from 2rohityadav/sonarqube-setup-angular.md
sonarqube setup with angular

SONAR Configuration - Angular

1) Install sonarqube-scanner -

npm install sonarqube-scanner --save-dev

2) Need to install few npm packages as a devDependencies

"devDependencies": {
@roman-bgonz
roman-bgonz / CreaTablaConListaAnidada.html
Last active February 11, 2023 00:09
Creates a table with nested list angular
<table id="customers">
<tr>
<th>Nombre</th>
<th>Tipo Fechs</th>
<th>Fecha</th>
<th>Enviar correo?</th>
</tr>
<ng-container *ngFor="let empleado of empleados">
<tr *ngFor="let field of empleado.aniversarios">
<td class="field">
@roman-bgonz
roman-bgonz / clone-repo-preserving-history
Last active October 11, 2023 19:49
Clone a repo preserving history
# If you're looking to preserve the existing branches and commit history, here's one way that worked for me.
git clone --mirror https://github.com/account/repo.git cloned-repo
cd cloned-repo
git push --mirror {URL of new (empty) repo}
# at this point only remote cloned-repo is correct, local has auto-generated repo structure with folders such as "branches" or "refs"
cd ..
rm -rf cloned-repo
git clone {URL of new (empty) repo}
@roman-bgonz
roman-bgonz / allow-re-spyOn.md
Last active February 11, 2023 00:08
Allow re spyOn angular testing

jasmine.getEnv().allowRespy(true);

OR

beforeEach(() => { spyOn(some, "method").and.returnValue(X) })

it("Test", () => { some.method = jasmine.createSpy().and.returnValue(Y)

@roman-bgonz
roman-bgonz / karma.conf.js
Created January 13, 2023 17:59
Karma config file to add assets to testing
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function (config) {
config.set({
basePath: "",
frameworks: ["jasmine", "@angular-devkit/build-angular"],
plugins: [
require("karma-jasmine"),
require("karma-chrome-launcher"),
@roman-bgonz
roman-bgonz / run-ng-domain.md
Created January 20, 2023 00:42
Test angular app as domain in local

1 Modify C:\Windows\System32\drivers\etc\hosts

  ip                    domain
  10.51.97.138		app.com

2 Generate certs to run app over https

  https://medium.com/@richardr39/using-angular-cli-to-serve-over-https-locally-70dab07417c8#fromHistory

3 Modify package.json as follows

"start": "ng serve --port 443 --host 0.0.0.0 --disable-host-check --ssl --ssl-key E:\certs\localhost.key --ssl-cert E:\certs\localhost.crt",

@roman-bgonz
roman-bgonz / PromiseVsObservable.js
Last active February 10, 2023 22:42
Demo to show promises vs observables (Use Code Runner Extension on VSCode)
const { Observable } = require('rxjs');
const { filter } = require('rxjs/operators');
/**
* PROMISE
*/
// A promise can only return a single value
const promesa = () => {
return new Promise((resolve, reject) => {