Skip to content

Instantly share code, notes, and snippets.

View michelepatrassi's full-sized avatar
🌊
Co-founder Sponsy | Ex WeTransfer

Michele michelepatrassi

🌊
Co-founder Sponsy | Ex WeTransfer
View GitHub Profile
@michelepatrassi
michelepatrassi / base64.js
Last active September 26, 2019 11:06
How to create base64 string and get it back in NodeJS
# Buffer is a default Nodejs global object
const initialString = 'michelepatrassi';
const token = Buffer.from(initialString).toString('base64');
# want to get it back?
const welcomeBack = Buffer.from(token, 'base64').toString('ascii');
if (initialString === welcomeBack) {
console.log('all good!');
@michelepatrassi
michelepatrassi / mutation-observer.ts
Created October 17, 2019 08:21
Angular MutationObserver
Component code
....
ngAfterViewInit() {
const config = { attributes: false, childList: true, subtree: true };
this.messageTreeObserver = new MutationObserver((mutationList, observer) => {
for (const mutation of mutationList) {
if (mutation.type === 'childList') {
// Do action here!
}
}
@michelepatrassi
michelepatrassi / uri-split.js
Created November 25, 2019 10:22
Helper to get path and name from file URI
getPathAndFileName(fileUri: string): { path: string; name: string } => {
const splittedUri = fileUri.split('/').filter(x => x);
const path = `${splittedUri.slice(0, -1).join('/')}/`;
const name = splittedUri.slice(-1).join();
return { path, name };
}
@michelepatrassi
michelepatrassi / server.ts
Last active February 5, 2023 13:56
Angular Universal Server Side Rendering battle tested server.ts and webpack.server.config.js files 🦁(includes Firebase, FirebaseUI, Angular i18n and log rotation)
import { RESPONSE, REQUEST } from '@nguniversal/express-engine/tokens';
import { renderModuleFactory } from '@angular/platform-server';
// These are important and needed before anything else
import 'zone.js/dist/zone-node';
import 'reflect-metadata';
import { enableProdMode, ValueProvider, FactoryProvider } from '@angular/core';
// Import module map for lazy loading
import {provideModuleMap} from '@nguniversal/module-map-ngfactory-loader';
import { registerLocaleData } from '@angular/common';
@michelepatrassi
michelepatrassi / daily-planning-example.txt
Last active April 6, 2020 13:28
Daily planning example
1/04/2020
8:30 - study nestJS
9:30 - team call
-> remember wrap to wrap up project task
10 - break
10:15 - deploy with cloud66 using docker compose, find out how to connect frontend with backend
-> deployment went fine, had to define custom file!
@michelepatrassi
michelepatrassi / gist:7e922900ea409d966f9a082ddceb5762
Created March 16, 2021 19:32
Format object to array of objects
const tags = {
Advertising: "Advertising",
Architecture: "Architecture",
Aviation: "Aviation",
Banking: "Banking",
Business: "Business",
Construction: "Construction",
Design: "Design",
Economics: "Economics",
Engineering: "Engineering",