Skip to content

Instantly share code, notes, and snippets.

View GaetanoPiazzolla's full-sized avatar
☠️
Sleep is for those without deadlines

Gaetano Piazzolla GaetanoPiazzolla

☠️
Sleep is for those without deadlines
View GitHub Profile
@GaetanoPiazzolla
GaetanoPiazzolla / override-storage.js
Created May 20, 2021 21:25
Overriding local and session storage
Storage.prototype._setItem = Storage.prototype.setItem
Storage.prototype._getItem = Storage.prototype.getItem
Storage.prototype.setItem = function(key, value) {
this._setItem(key, CryptoJS.AES.encrypt(value, 'privatekey').toString())
}
Storage.prototype.getItem = function(key) {
let value = this._getItem(key)
if (value) {
@Injectable({
providedIn: 'root'
})
export class SingletonSecureStorageService {
constructor() {
}
init() {
// overriding window function here
import {APP_INITIALIZER} from '@angular/core'
import {SingletonSecureStorageService} from './services/.... '
@NgModule({
declarations: [ /*.. components...*/ ],
imports: [ /*.. modules .. */],
providers: [
SingletonSecureStorageService,
{
{
// .....
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
@GaetanoPiazzolla
GaetanoPiazzolla / jquery-hidden.js
Created July 14, 2021 09:12
jquery with hidden version number.
/*! jQuery XXXX | (c) JS Foundation and other contributors | jquery.org/license */
!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery XXX requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],E=C.document,r=Object.getPrototypeOf,s=t.slice,g=t.concat,u=t.push,i=t.indexOf,n={},o=n.toString,v=n.hasOwnProperty,a=v.toString,l=a.call(Object),y={},m=function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},x=function(e){return null!=e&&e===e.window},c={type:!0,src:!0,nonce:!0,noModule:!0};function b(e,t,n){var r,i,o=(n=n||E).createElement("script");if(o.text=e,t)for(r in c)(i=t[r]||t.getAttribute&&t.getAttribute(r))&&o.setAttribute(r,i);n.head.appendChild(o).parentNode.removeChild(o)}function w(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?n[o.call(e)]||"object":typeof e}var f="3.4.1",k=function(
@GaetanoPiazzolla
GaetanoPiazzolla / env-configmap.yaml
Last active July 21, 2021 08:35
A standard k8s ConfigMap
apiVersion: v1
data:
ENV_API_BACKEND_URL: http://localhost:8080/bananas
ENV_EXTERNAL_INTEGRATION_URL: http://www.integration.com/easy
kind: ConfigMap
metadata:
name: the_configmap_name_id
@GaetanoPiazzolla
GaetanoPiazzolla / env-configmap-from.yaml
Created July 21, 2021 07:42
Using config map as valueFrom
... containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "/bin/sh", "-c", "env" ]
env:
- name: ENV_API_BACKEND_URL
valueFrom:
configMapKeyRef:
name: the_configmap_name_id
key: ENV_API_BACKEND_URL
@GaetanoPiazzolla
GaetanoPiazzolla / env-configmap-envFrom.yaml
Created July 21, 2021 07:44
Using configmap as envFrom
. . . containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "/bin/sh", "-c", "env" ]
envFrom:
- configMapRef:
name: the_configmap_name_id
@GaetanoPiazzolla
GaetanoPiazzolla / env.js
Last active July 21, 2021 08:35
The env file at runtime
(function (window) {
window["env"] = window["env"] || {};
window["env"].API_BACKEND_URL = 'http://localhost:8080/bananas'; // not actualized, for local testing
window["env"].EXTERNAL_INTEGRATION_URL = 'http://www.integration.com/easy'; // not actualized, for local testing
})(this);
@GaetanoPiazzolla
GaetanoPiazzolla / index.html
Created July 21, 2021 07:55
The index.html with the script including env.js
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/">
<script src="assets/env.js" ></script>
</head>
<body>
</body>