Skip to content

Instantly share code, notes, and snippets.

@meetbryce
meetbryce / projects.tsx
Created September 25, 2022 15:56
Data only loads after internal navigation
import {GetServerSideProps, InferGetServerSidePropsType, NextPage} from 'next';
import styles from '../styles/Home.module.css';
import Footer from '../components/Footer';
import Header from '../components/Header';
import Meta from '../components/Meta';
import {useEffect, useState} from 'react';
import Link from 'next/link';
import {supabaseClient, withPageAuth} from '@supabase/auth-helpers-nextjs';
export const getServerSideProps: GetServerSideProps = withPageAuth({redirectTo: '/auth'});
@meetbryce
meetbryce / projects.tsx
Created September 23, 2022 21:50
Data loads only sometimes
import {GetServerSideProps, InferGetServerSidePropsType, NextPage} from 'next';
import styles from '../styles/Home.module.css';
import Footer from '../components/Footer';
import Header from '../components/Header';
import Meta from '../components/Meta';
import {useEffect, useState} from 'react';
import Link from 'next/link';
import {supabaseClient, withPageAuth} from '@supabase/auth-helpers-nextjs';
export const getServerSideProps: GetServerSideProps = withPageAuth({redirectTo: '/auth'});
@meetbryce
meetbryce / auth.tsx
Last active September 23, 2022 18:36
Too many redirects
import {NextPage} from 'next';
import {supabaseClient} from '@supabase/auth-helpers-nextjs';
import {useUser} from '@supabase/auth-helpers-react';
import {useEffect, useState} from 'react';
import {Auth} from '@supabase/ui';
import styles from '../styles/Home.module.css';
import Meta from '../components/Meta';
import Header from '../components/Header';
import Footer from '../components/Footer';
import {useRouter} from 'next/router';
@meetbryce
meetbryce / profile.tsx
Created September 23, 2022 15:08
Hydration error while using helper
import {NextPage} from 'next';
import styles from '../styles/Home.module.css';
import Meta from '../components/Meta';
import Header from '../components/Header';
import Footer from '../components/Footer';
import {withPageAuth} from '@supabase/auth-helpers-nextjs';
export const getServerSideProps = withPageAuth({redirectTo: '/login'});
const Profile: NextPage = ({user}) => {
@meetbryce
meetbryce / supabase.tsx
Created September 23, 2022 14:47
Hydration error using Auth.useUser()
import {Auth} from '@supabase/ui';
import styles from '../styles/Home.module.css';
import Meta from '../components/Meta';
import Header from '../components/Header';
import {supabase} from '../lib/initSupabase';
// export async function getStaticProps() {}
const LoginPage = () => {
const {user} = Auth.useUser();
@meetbryce
meetbryce / machine.js
Last active June 29, 2020 11:54
Generated by XState Viz: https://xstate.js.org/viz
const machine = Machine({
id: 'machine',
type: 'parallel',
states: {
order: {
initial: 'DoesNotExist',
states: {
DoesNotExist: {
on: {
MB_send_order: 'UNSENT',
@meetbryce
meetbryce / machine.js
Last active June 16, 2020 15:53
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine({
id:'newOrder',
initial: 'DoesNotExist',
states: {
DoesNotExist: {
on: {
MB_create_order: 'UNSENT',
}
},
UNSENT: {
@meetbryce
meetbryce / .zshrc
Last active December 9, 2019 18:03
Autoload virtualenv from .venv when moving into a directory
# autoload venv if there's a .venv file
# Support for bash
PROMPT_COMMAND='prompt'
# Mirrored support for zsh. See: https://superuser.com/questions/735660/whats-the-zsh-equivalent-of-bashs-prompt-command/735969#735969
precmd() { eval "$PROMPT_COMMAND" }
function prompt()
{
if [ "$PWD" != "$MYOLDPWD" ]; then
@meetbryce
meetbryce / script.js
Last active June 18, 2018 06:44
Calculate binary statistical significance (with 99% confidence)
// require('jStat');
function calculateSignificance(a_sessions, a_conversions, b_sessions, b_conversions) {
a_cr = a_conversions / a_sessions;
b_cr = b_conversions / b_sessions;
a_stdErr = Math.sqrt(a_cr * (1 - a_cr) / a_sessions);
b_stdErr = Math.sqrt(b_cr * (1 - b_cr) / b_sessions);
// get_z_score()
const z_score =
@meetbryce
meetbryce / setup.md
Created October 17, 2017 23:27 — forked from shashankmehta/setup.md
Setup PHP and Composer on OSX via Brew

First install Brew on your MAC

  • Setup Brew: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • brew update
  • brew tap homebrew/dupes
  • brew tap homebrew/php
  • Install PHP 7.0.+ brew install php70
  • Install mcrypt: brew install mcrypt php70-mcrypt
  • Finally, install composer: brew install composer