Skip to content

Instantly share code, notes, and snippets.

Lee Cooper lski

Block or report user

Report or block lski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
lski / createLogger.js
Last active Nov 2, 2019
Create a logger that will only log values if the initial currentLevel is equal to or greater than the initially passed in level
View createLogger.js
* 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
lski / toMarkdownTable.js
Created Oct 27, 2019
Converts a list of objects to a Markdown table
View toMarkdownTable.js
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 '';
lski / AutheticationProvider.jsx
Created Oct 6, 2019
Wrappers the Okta Auth for React, includes support for hooks
View AutheticationProvider.jsx
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,
lski / localStorage.js
Created Oct 2, 2019
A simple localStorage wrapper storing objects, rather than strings
View localStorage.js
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) {
lski / VsCode.ps1
Created Apr 22, 2019
A backup and restore script for VSCode
View VsCode.ps1
$root = if($PSScriptRoot) { $PSScriptRoot } else { '.' }
function Backup-VsCode(
$backupDir = "$root"
) {
if($null -ne ($code = FindVsCodeExe)) {
Extract-VsCodeSettings -backupDir $backupDir
lski / Launch.cs
Created Apr 18, 2019
Launch a web broswer with optional URL on Win/Mac/Linux
View Launch.cs
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace WebBrowser
public static class Browser
public static Process Launch(string url, string browser = null)
lski / HttpClientWrapper.cs
Created Apr 18, 2019
A wrapper for HttpClient to allow for mocking... however do not use, see readme
View HttpClientWrapper.cs
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
namespace HttpWrapper
/// <summary>
/// A concrete implementation of IHttpClient, which can be used easily for mocking
/// </summary>
lski / GuidExtensions.cs
Last active Apr 16, 2019
A short format GUID/UUID based on Mads Kristensens work
View GuidExtensions.cs
public static class GuidExtensions {
/// <summary>
/// Converts a Guid into a short format useful urls
/// </summary>
/// <remarks>
/// See <see></see> for a more detailed explantion.
/// </remarks>
public static string ToShortFormat(this Guid guid) =>
lski / wslpath.ps1
Created Apr 6, 2019
wslpath wrapper for using directly in powershell
View wslpath.ps1
Converts windows path into a linux path and vice versa.
Converts windows path into a linux path and vice versa. Use WSL under the hood, so needs to be installed.
See docs wslpath docs for more information.
The path to convert
lski / createElement.js
Last active Sep 22, 2019
Shorthand function for document.createElement, with added functionality... very similar to Reacts createElement :/ lol
View createElement.js
* Shorthand function for document.createElement. Accepts and appends attributes to the newly created element and appends child element, if any.
* @param tagName The name of the element eg. a or script
* @param attributes Any additional attributes to add to the element after creating. Eg. href
* @param children Any child elements you want appended on creating this element, obviously they could be createElement calls as well
export function createElement(tagName, attributes, children) {
const ele = attributes === (void 0)
? document.createElement(tagName)
: Object.assign(document.createElement(tagName), attributes);
You can’t perform that action at this time.