Skip to content

Instantly share code, notes, and snippets.

View ScreamZ's full-sized avatar

Andréas Hanss ScreamZ

View GitHub Profile
import "tailwindcss/tailwind.css";
import type { CodingSparkAppProps } from "modules/nextjs";
import { LayoutFactory } from "modules/ui/layouts/LayoutFactory";
import { DefaultSeo } from "next-seo";
import React from "react";
function MyApp({ Component, pageProps }: CodingSparkAppProps) {
const { layout } = Component;
import type { CodingSparkPageLayoutProps } from "modules/nextjs";
import dynamic from "next/dynamic";
const NotAuthenticatedLayout = dynamic(() => import("modules/ui/layouts/NotAuthenticatedLayout"));
const OnboardingLayout = dynamic(() => import("modules/ui/layouts/OnboardingLayout"));
export const LayoutFactory: React.FC<{ layout: CodingSparkPageLayoutProps["layout"] }> = ({
layout = { type: "none" },
children,
}) => {
import type { NotAuthenticatedLayoutArgs } from "modules/ui/layouts/NotAuthenticatedLayout";
import type { OnboardingLayoutArgs } from "modules/ui/layouts/OnboardingLayout";
import type { NextPage } from "next";
import type { AppProps } from "next/app";
interface LayoutArgs {
layout?: { type: string };
}
export interface CodingSparkPageLayoutProps extends LayoutArgs {
import { BasicStrategy as Strategy } from 'passport-http';
import { Injectable, InternalServerErrorException, UnauthorizedException } from '@nestjs/common';
import { PassportStrategy } from '@nestjs/passport';
import { ConfigService } from '@nestjs/config';
import { timingSafeEqual } from 'crypto';
@Injectable()
export class AdminBasicStrategy extends PassportStrategy(Strategy) {
constructor(private readonly configService: ConfigService) {
super();
@ScreamZ
ScreamZ / react-hook-form-yup-typescript.ts
Created September 15, 2021 10:56
Use form hooks Typesript
import { yupResolver } from '@hookform/resolvers/yup';
import { useForm, UseFormProps, UseFormReturn } from 'react-hook-form';
import * as Yup from 'yup';
/**
* This function is type inference ready and will auto-validate the useForm with the proper values.
*
* If you don't already have the schema or use a dynamic schema, consider useFormWithSchemaBuilder()
*
* @param schema - A valid you schema
import crypto from "crypto";
import merge from "lodash/merge";
import { AppConfig, PrivateConfig, PublicConfig } from "./types";
/**
* Factory function that takes a public config and a HEX encrypted configuration.
* On call, this function will decipher, both configuration will be merged together to provide a single JSON object representating the configuration.
*
* @param {PublicConfig} publicConfig
* @param {string} hexEncodedPrivateConfig
const events = require("events");
// Vars
let interestedUsers = [];
const goodPlanTopic = new events.EventEmitter();
function startListeningForMessages(topic, listeningUsers) {
// Each time a message is received, we sent a notification to user interest in our topic
function onNewMessage(newMessage) {
listeningUsers.forEach(user =>
import firebase from "firebase/app";
import { createContext, useContext, useEffect, useState } from "react";
import { LoginPrompt } from "./components/LoginPrompt";
const AuthContext = createContext<firebase.User | null>(null);
export const AuthContextProvider: React.FC = props => {
const [user, setUser] = useState<firebase.User | null>(null);
const [loginError, setLoginError] = useState<string | null>(null);
// Import here to bypass non-SSR issues with EUI
@import "~@elastic/eui/src/theme_light.scss";
const _ = require("lodash");
class CardShuffler {
constructor(deck) {
this.deck = _.shuffle(deck);
this.activeCards = [];
}
/**
* Get an iterator that will iterate through the cards.