Skip to content

Instantly share code, notes, and snippets.

@adriancuadrado
adriancuadrado / msal-cheatsheet.js
Last active November 7, 2023 20:20
MSAL.js cheatsheet
// Initialization
const myMSALObj = new msal.PublicClientApplication({
auth: {
clientId: "c993fdd7-f80e-4586-bd81-8753a1f3e5ac", // This is the ONLY mandatory field; everything else is optional.
authority: "https://MyOrgName2349865.b2clogin.com/MyOrgName2349865.onmicrosoft.com/B2C_1_susi", // Choose sign-up/sign-in user-flow as your default.
knownAuthorities: ['MyOrgName2349865.b2clogin.com'], // You must identify your tenant's domain as a known authority.
redirectUri: "http://localhost:6420" // You must register this URI on Azure Portal/App Registration. Defaults to "window.location.href".
},
cache: {
cacheLocation: "sessionStorage", // Configures cache location. "sessionStorage" is more secure, but "localStorage" gives you SSO between tabs.
@adriancuadrado
adriancuadrado / gist:5c3b2dd63e21908a64812412cd30b23a
Last active October 4, 2023 10:08
How to get started with React Native in a real device
  1. Follow the instructions from React Native's documentation
  2. Make 1000% sure the USB cable works for this and not just charging. Not all of them do apparently.
  3. Execute this with the USB cable connected:
    adb kill-server
    adb tcpip 5555
    adb connect <your-android-device-ip-address-or-network-name>:5555
    

    You only need to execute the 2 first steps once and the last one every time your computer boots up

  4. Open the 'android' folder with Android Studio and let it download and install the gradle dependencies.
@adriancuadrado
adriancuadrado / export.js
Created July 11, 2022 23:03
Import/export indexedDB database
(() => {
indexedDB.open('postman-app').onsuccess = async event => {
let db = event.target.result;
let transaction = db.transaction(db.objectStoreNames);
// TODO: Create and download a file instead of outputting the contents
console.log(
Object.fromEntries(
await Promise.all(
[...db.objectStoreNames]
.map(
@adriancuadrado
adriancuadrado / 00_export_history.js
Last active February 23, 2023 08:52
Scripts to import/export Postman's history
(async function() {
const filename = 'postman-history-export.json';
const download = (function() {
const element = document.createElement('a');
return function(filename, contents) {
element.setAttribute('href', URL.createObjectURL(new Blob([contents])));
element.setAttribute('download', filename);
element.click();
@adriancuadrado
adriancuadrado / style.css
Last active June 23, 2021 09:36
CSS for less youtube distractions
/*
Download a plugin for your browser to load custom css, then use this to hide all youtube recomendations and avoid distractions.
For instance, you can download Stylebot: https://stylebot.dev/
*/
div.style-scope.ytd-rich-grid-renderer {
display: none;
}
div.style-scope.ytd-compact-video-renderer {