Skip to content

Instantly share code, notes, and snippets.

View itwasmattgregg's full-sized avatar
:octocat:
Artisinally crafting interwebs

Matt Gregg itwasmattgregg

:octocat:
Artisinally crafting interwebs
View GitHub Profile
@itwasmattgregg
itwasmattgregg / Blend Mode Loading Spinner.html
Last active September 14, 2016 16:35
Generated by SassMeister.com.
<div class="loading">
<span class="bar bar-1"></span>
<span class="bar bar-2"></span>
<span class="bar bar-3"></span>
<span class="bar bar-4"></span>
</div>
@itwasmattgregg
itwasmattgregg / Top arrow with inner shadow.css
Last active September 23, 2016 21:15
Generated by SassMeister.com.
section {
padding: 40px 0px;
background-color: #fff;
width: 100%;
}
.border-top {
background-color: #eee;
position: relative;
box-shadow: 0 2px 4px #ccc inset;
@itwasmattgregg
itwasmattgregg / index.js
Created June 28, 2018 15:32 — forked from codediodeio/index.js
Firebase Cloud Functions image thumbnail generator using Sharp for 4x faster resizing
const functions = require('firebase-functions');
const gcs = require('@google-cloud/storage')();
const sharp = require('sharp')
const _ = require('lodash');
const path = require('path');
const os = require('os');
exports.generateThumbnail = functions.storage.object('uploads/{imageId}').onChange(event => {
const object = event.data; // The Storage object.
@itwasmattgregg
itwasmattgregg / main.js
Created October 17, 2019 21:26
WP Vue Main
import "@babel/polyfill";
import Vue from "vue";
import * as VueGoogleMaps from "vue2-google-maps";
import VTooltip from "v-tooltip";
import router from "@/router";
import store from "@/store";
import Search from "@/Search.vue";
import { PostPartialUpdateRequest, PostUpdateRequest, ExternalLink, Post } from "../gen/api";
import { Component } from "react";
import { apiCall, postApi, externalLinkApi } from "../Api";
export type PostCreateUpdateRequest = Post;
function isPostUpdateRequest(request: PostCreateUpdateRequest): request is PostPartialUpdateRequest | PostUpdateRequest {
return (request as PostPartialUpdateRequest).id !== undefined;
}
@itwasmattgregg
itwasmattgregg / firebase.json
Last active May 23, 2020 17:56
Automate firebase hosting with github actions
{
"hosting": {
"site": "site-name",
"public": "dist",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
@itwasmattgregg
itwasmattgregg / main.yml
Created May 23, 2020 17:57
Automate firebase hosting with github actions
name: Build and Deploy
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
import { withSessionSsr } from '@utils/session';
export default function Admin() {
// Users will never see this unless they're logged in.
return <h1>Secure page</h1>;
}
export const getServerSideProps = withSessionSsr(async function ({ req, res }) {
const user = req.session.user;
import { useState } from 'react';
import useUser from '@utils/useUser';
export default function Login() {
// here we just check if user is already logged in and redirect to admin
const { mutateUser } = useUser({
redirectTo: '/admin',
redirectIfFound: true,
});
import { useEffect } from 'react';
import Router from 'next/router';
import useSWR from 'swr';
export default function useUser({
redirectTo = false,
redirectIfFound = false,
} = {}) {
const { data: user, mutate: mutateUser } = useSWR('/api/user');