This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$root = if($PSScriptRoot) { $PSScriptRoot } else { '.' } | |
function Backup-VsCode( | |
[string] | |
$backupDir = "$root" | |
) { | |
if($null -ne ($code = FindVsCodeExe)) { | |
Extract-VsCodeSettings -backupDir $backupDir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function setLocationStorage(key, value) { | |
localStorage.setItem(key, JSON.stringify(value)); | |
return value; | |
} | |
function getLocationStorage(key, clear = false) { | |
const value = localStorage.getItem(key); | |
if(clear === true) { | |
removeLocationStorage(key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { createContext, useContext, useMemo, useState, useEffect } from "react"; | |
import { Route, withRouter } from "react-router-dom"; | |
import { Auth } from "@okta/okta-react"; | |
import { useExpensiveRef } from '../features/useExpensiveRef'; | |
import { Redirect } from "react-router"; | |
import { getLocationStorage } from "../utils/localStorage"; | |
import { log } from '../utils/log'; | |
const settings = { | |
issuer: process.env.REACT_APP_OKTA_ISSUER, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const toMarkdownTable = (keys = null) => (list) => { | |
if (list == null) throw new Error('The list needs to be an array'); | |
if (list.length === 0) return ''; | |
keys = keys || Object.keys(list[0]); | |
if (keys.length === 0) return ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Creates a logger that optional runs depending on the current level set for logging in the application | |
* | |
* Levels: | |
* 0 = debug | |
* 1 = trace (alias for verbose) | |
* 2 = info | |
* 3 = warn | |
* 4 = error | |
* 5+ = none |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
/** | |
* Accepts a full file path and checks whether the file exists returning the answer | |
* If it doesnt exist it will also attempt to create the file. | |
* | |
* @param {string} filepath The file to check and create. | |
*/ | |
export const fileExistsAndCreate = filepath => { | |
return new Promise((resolve, reject) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Handles cleanup after basic close events, if the handler returns nothing | |
* | |
* @param {Function} handler | |
* @param {Array<string>} [events=['SIGINT', 'uncaughtException', 'exit']] | |
*/ | |
export const onProcessExit = ( | |
handler, | |
events = ['SIGINT', 'uncaughtException', 'exit'] | |
) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Does a simple (single level) sort on the properties in an object. | |
* @returns {Map} | |
*/ | |
function sortObjectProps(json) { | |
return Object.keys(json) | |
.sort((a, b) => a >= b) | |
.reduce((accumulator, item) => { | |
accumulator.set(item, json[item]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Opens the current folder in the Windows Terminal | |
function term() { | |
# Open's terminal | |
function __runTerm() { | |
# Using the wslpath tool to convert the current directory to windows format | |
# which is required by wt. Also using printf to escape the characters so they arent expanded | |
local var=$(printf "%q" "$(wslpath -w $(pwd))") | |
# Run wt using powershell command |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
export const createStorage = (key, scope = localStorage) => { | |
return { | |
get() { | |
const stored = scope.getItem(key); | |
if (stored === null) { | |
return null; | |
} | |
return JSON.parse(stored); | |
}, |