Skip to content

Instantly share code, notes, and snippets.

View smashboy's full-sized avatar
🌴

SmashBoy smashboy

🌴
View GitHub Profile
@smashboy
smashboy / appWindow.ts
Created September 7, 2020 09:59
appWindow
import { BrowserWindow, app } from 'electron';
import { connections } from '../../main';
import { closePreloaderWindow } from '../preloaderWindow/preloaderWindow';
let appWindow: null | BrowserWindow = null;
export const createAppWindow = () => {
appWindow = new BrowserWindow({
width: 970,
height: 610,
@smashboy
smashboy / usePusher.rs
Created March 5, 2021 19:36
React hook usePusher
import React from "react";
import Pusher, { Channel } from "pusher-js";
const pusher = new Pusher(process.env.NEXT_PUBLIC_PUSHER_KEY, {
cluster: process.env.NEXT_PUBLIC_PUSHER_CLUSTER,
});
type EventPropsType<R> = {
event: string;
onEvent: (data: R) => void;
@smashboy
smashboy / index.ts
Last active March 15, 2021 16:41
Next API Routes / Pusher Issue
// Pusher setup in separate file
import Pusher from "pusher";
const pusher = new Pusher({
appId: process.env.PUSHER_APP_ID,
key: process.env.NEXT_PUBLIC_PUSHER_KEY,
cluster: process.env.NEXT_PUBLIC_PUSHER_CLUSTER,
secret: process.env.PUSHER_SECRET,
});
import React from "react";
import { Button, Grid } from "@material-ui/core";
import useCollection from "../../hooks/useCollection";
import useNotifications from "../../hooks/useNotifications";
import useFetch from "../../hooks/useFetch";
import useAsync from "../../hooks/useAsync";
import {
PostDashboardWinResponseType,
PostWidgetRequestType,
} from "../../types/api";
import React from "react";
import { useRouter } from "next/router";
import {
Backdrop,
createStyles,
Theme,
makeStyles,
Box,
} from "@material-ui/core";
import {
export type UseQuardQueryPropsType<T extends QueryFn, TResult> = {
params: FirstParam<T>;
options?: QueryOptions<TResult>;
rules: useGuardInputType<
ResourceType<ExtendedResourceTypes>, // Your custom resources
AbilityType<ExtendedAbilityTypes> // Your custom abilities
>[];
rulesMatch?: "every" | "some";
};
import React from "react";
import { Control, Controller, useWatch } from "react-hook-form";
import {
Grid,
Slider,
TextField,
Typography,
useMediaQuery,
useTheme,
} from "@material-ui/core";
import { NextApiRequest, NextApiResponse } from "next";
import multer from "multer";
import nextConnect from "next-connect";
import stream from "stream";
import { storage } from "../../firebase";
export type SaveEmbedImageReturnType = {
imageURL: string;
};
import { DialogTitle } from "@material-ui/core";
import Dialog from "app/core/components/Dialog";
import RewardForm from "./RewardForm";
import { useTwitchSettings } from "app/collection-settings/hooks/useTwitchSettings";
import { useCustomMutation } from "app/core/hooks/useCustomMutation";
import createTwitchEventReward from "app/collection-settings/mutations/twitch/createTwitchEventReward";
import updateTwitchEventReward from "app/collection-settings/mutations/twitch/updateTwitchEventReward";
import { EventSelectorReward } from "app/collection-settings/queries/getTwitchSettings";
const EventRewardDialog: React.FC<{
@smashboy
smashboy / GenerateLocalesTypesPlugin.ts
Last active September 25, 2021 12:25
Dynamic locales import + webpack plugin for generating types from json
import path from "path";
import { getConfig } from "blitz";
import { readdir, stat, writeFile, readFile } from "fs/promises";
import {
quicktype,
InputData,
jsonInputForTargetLanguage,
TypeScriptTargetLanguage,
} from "quicktype-core";