Skip to content

Instantly share code, notes, and snippets.

@shepardm7
shepardm7 / ReactConditionalHookCompFactory.tsx
Created June 19, 2023 16:13
React conditional hook component factory
import {useState} from "react";
interface Opts<TPropsHook extends Record<string, any>, THookReturn extends TPropsHook> {
componentName: string;
useConditionalHook: (props: TPropsHook) => THookReturn | null;
WrappedComponent: (props: THookReturn) => JSX.Element;
ComponentForNull?: (props: TPropsHook) => JSX.Element;
}
const conditionalHookFactory = <TPropsHook extends Record<string, any>, THookReturn extends TPropsHook>({
componentName, useConditionalHook, WrappedComponent, ComponentForNull
@shepardm7
shepardm7 / JetBrains Windows Context Menu Item Util.md
Last active May 29, 2021 18:34
Add `Open with IDE` to Windows right click context menu
git config --global alias.lg "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
@shepardm7
shepardm7 / myscript.sh
Last active June 4, 2021 17:09 — forked from bradtraversy/myscript.sh
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
echo "My name is $NAME"
@shepardm7
shepardm7 / Redirect http to https.js
Created July 4, 2018 15:42
How to automatically redirect http to https using javascript
var loc = window.location.href+'';
if (loc.indexOf('http://')==0){
window.location.href = loc.replace('http://','https://');
}
//Source: https://stackoverflow.com/questions/4954768/automatic-redirection-to-https