Skip to content

Instantly share code, notes, and snippets.

View DistractionBoy's full-sized avatar
🔴
Optimistic Pioneer

DistractionBoy DistractionBoy

🔴
Optimistic Pioneer
View GitHub Profile
import {
HomeIcon,
FireIcon,
UserGroupIcon,
TrendingUpIcon,
} from "@heroicons/react/outline";
import { useRouter } from "next/router";
import React, { useEffect, useState } from "react";
import { NavLink } from "../lib";
import { classNames } from "../lib/helpers";
@DistractionBoy
DistractionBoy / README.md
Created June 27, 2022 17:37 — forked from lopspower/README.md
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

import { Step } from "../../components/Stepper";
import { createCtx } from "./createCtx";
import * as R from "ramda";
export const stepperInitialState: Step[] = [
{
id: "1",
name: "Connect",
description: "wallet and check network",
href: "",
function range(size, startAt = 0) {
return [...Array(size).keys()].map(i => i + startAt);
}
@DistractionBoy
DistractionBoy / createCtx.tsx
Last active August 11, 2022 19:39
quick react context with reducer
export function createCtx<StateType, ActionType>(
reducer: React.Reducer<StateType, ActionType>,
initialState: StateType,
) {
const defaultDispatch: React.Dispatch<ActionType> = () => initialState // we never actually use this
const ctx = React.createContext({
state: initialState,
dispatch: defaultDispatch, // just to mock out the dispatch type and make it not optioanl
})
function Provider(props: React.PropsWithChildren<{}>) {
const removeUndefinedForNextJsSerializing = <T,>(props: T): T =>
Object.fromEntries(
Object.entries(props).filter(([, value]) => value !== undefined)
) as T;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type ActionMap<M extends { [index: string]: any }> = {
[Key in keyof M]: M[Key] extends undefined
? {
type: Key
}
: {
type: Key
payload: M[Key]
}
/**
* this function replaces atob() which is a method of the window object and does not run
* properly on node. it takes a base64 encoded string and DECODES it into a js obj
* ----found at ----> https://gist.github.com/oeon/0ada0457194ebf70ec2428900ba76255
*/
export const a2b = (a: string): string => {
let b, c, d
const e = {}
let f = 0
let g = 0
did:3:kjzl6cwe1jw1497l6u16iux4zwuoudouy9hdyvwnlc1bc9bhxcsepr7wx913h8c
@DistractionBoy
DistractionBoy / gist:fbeca9e3576162041e3a09d730d9fbfe
Last active September 6, 2017 20:20
angular ObserverService
(function () {
angular
.module('myApp')
.service('ObserverService', ObserverService);
function ObserverService () {
var vm = this;
vm.data = {};
vm.callbacks = {};