Skip to content

Instantly share code, notes, and snippets.

View click2install's full-sized avatar
:octocat:
Clicking, double clicking, sending email, receiving email ... I could go on.

click2install click2install

:octocat:
Clicking, double clicking, sending email, receiving email ... I could go on.
View GitHub Profile
@click2install
click2install / IconResources.tt
Last active January 13, 2020 14:37
T4 Template for generating a typed C# class of Lazy XAML resources
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Linq" #>
<#@ assembly name="System.Xml" #>
<#@ assembly name="System.Xml.Linq" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Xml.Linq" #>
@click2install
click2install / setup.py
Last active July 8, 2019 13:29
Multiple masternode address setup and collateral send
#!/usr/bin/python
# usage:
# ensure wallet config has these items without the # prefix, restart the wallet
# if they need to be added to the config:
#
# server=1
# rpcuser=anrpcusername
# rpcpassword=apassword
#
@click2install
click2install / DebugRouter.js
Created July 22, 2019 14:01
React DebugRouter
import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import Login from 'components/Login'
import DefaultComponent from 'components/DefaultComponent'
class DebugRouter extends Router {
constructor(props){
super(props);
console.log('initial history is: ', JSON.stringify(this.history, null,2))
this.history.listen((location, action)=>{
@click2install
click2install / useFadeOut.js
Last active August 12, 2021 08:25
[useFadeOut] - ReactJS hook to fadeOut an element using the opacity and display styles.
import {useLayoutEffect, useRef} from "react";
export default function useFadeOut(ref, fadeTime, visible)
{
const timerId = useRef();
useLayoutEffect(() =>
{
clearTimeout(timerId.current);
@click2install
click2install / ThemeProvider.tsx
Last active August 12, 2021 08:34
[ThemeProvider] - A FluentUI React theme context provider.
import { AzureCustomizationsLight, AzureCustomizationsDark } from "@uifabric/azure-themes";
import { ThemeProvider as FluentThemeProvider } from "@fluentui/react-theme-provider";
import React, { createContext, PropsWithChildren, useContext, useState } from "react";
import { useLocalStorage } from "../hooks/useLocalStorage";
interface IThemeContext
{
themeName: string;
@click2install
click2install / App.js
Last active August 12, 2021 08:36
[Avatar] - A React avatar component for autogenrating avatar based on a given name.
import React from "react";
import { Avatar } from "./Avatar";
export default function App()
{
return (
<div className="App">
<Avatar name="display middle name" background="#1FDA8A" size={32} highContrast={false} rounded={false} bold={true} />
</div>
@click2install
click2install / usage.ts
Last active August 12, 2021 08:33
[useLogStateChanges] - A React hook to log state changes within a functional component or hook.
// using ts-nameof
useLogStateChanges(nameof(SomeComponent),
[
[nameof(value), value],
[nameof(startDate), startDate, val => (val as Date).valueOf().toString()],
[nameof(endDate), endDate]
]);
// using strings :(
useLogStateChanges("SomeComponent",
@click2install
click2install / HttpStatus.ts
Last active August 12, 2021 08:41
[HttpStatus] - A TypeScript HTTP status code enumeration
export enum HttpStatus
{
Continue = 100,
SwitchingProtocols = 101,
Processing = 102,
EarlyHints = 103,
OK = 200,
Created = 201,
Accepted = 202,
@click2install
click2install / Guid.test.ts
Last active August 12, 2021 08:29
[Guid] - Typescript Guid with a similar API to a C# Guid struct
import { expect } from "chai";
import { describe, it } from "mocha";
import * as faker from "faker";
import { Guid, GuidFormat } from "../Guid";
describe(nameof(Guid), () =>
{
const empty = "00000000-0000-0000-0000-000000000000";
@click2install
click2install / i18nKeysGenerator.js
Last active August 12, 2021 08:28
[i18nKeyGenerator] - Build utility for generating a typed object for typed access to i18n keys.
// util to code generate an object from another object where all the resulting object
// keys equal their respective paths within the object.
//
// useful for removing magic i18n strings from code.
/* eslint-disable @typescript-eslint/no-var-requires */
const dot = require("dot-object");
const fs = require("fs");
const path = require("path");