Skip to content

Instantly share code, notes, and snippets.

@roman-bgonz
roman-bgonz / notification.html
Created February 16, 2023 15:03
Javascript notifications
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Javascript Notification</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
</head>
<body>
@roman-bgonz
roman-bgonz / js-page-title.html
Created February 14, 2023 23:51
Changes title to tab when user changes to another tab
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" type="text/css" media="screen" href="main.css" />
<script>
// Our current page title
@roman-bgonz
roman-bgonz / uppercase-object-key.js
Last active February 17, 2023 00:58
Uppercase object key name
const obj = {name: "Name", position: "developer"}
const keyToUpper = (obj: any) =>
Object.keys(obj).reduce((acc, k) => {
acc[k.toUpperCase()] = obj[k];
return acc;
}, {});
console.log(keyToUpper(obj))
@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) => {
@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 / 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 / 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 / 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 / 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 / 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": {