Skip to content

Instantly share code, notes, and snippets.

@danalloway
danalloway / migrate-gcs-supabase.js
Last active March 29, 2024 06:19
Migrate Google Cloud Storage (GCS) to Supabase Storage
/**
* 1.) Make sure you have the `GOOGLE_APPLICATION_CREDENTIALS` environment variable
* set to the path of your local service account credentials.
* @see https://cloud.google.com/storage/docs/reference/libraries#setting_up_authentication
*
* 2.) Make sure you have the `SUPABASE_URL` and `SUPABASE_KEY` environment variables set
* with the proper values from your Supabase Project API page.
*
* Install dependancies: `npm install --save node-fetch form-data @google-cloud/storage`
*/
@danalloway
danalloway / supabase_upload_stream.js
Created April 2, 2021 02:57
Supabase Storage - Upload Stream
const fetch = require("node-fetch");
const FormData = require("form-data");
const API_URL = process.env.SUPABASE_URL;
const AUTH_TOKEN = process.env.SUPABASE_KEY;
/**
* @async
* @param {string} bucketId
* @param {string} path
@danalloway
danalloway / global.css
Last active February 27, 2021 19:30
Remix v0.9.x & Tailwind v2.x
/* ./styles/global.css */
@import url('https://rsms.me/inter/inter.css');
@tailwind base;
@tailwind components;
/* custom styles */
@tailwind utilities;
@danalloway
danalloway / ActivityProvider.js
Last active July 9, 2019 15:54
React Providers using Context / State / Hooks
/**
* 1.) Context. For lifting our state up to any tree below the Provider.
*/
const ActivityContext = createContext()
/**
* 2.) Provider. For sharing our state across many render trees.
*/
export const ActivityProvider = ({ children }) => {
const [activity, setActivity] = useState([])
import React from "React"
import hoistNonReactStatic from "hoist-non-react-statics"
const withHOC = hocProps => WrappedComponent => {
// use `hocProps` to configure how the HOC behaves towards it's `WrappedComponent`
const { debug } = hocProps
if (debug) {
console.debug("withHoc is in DEBUG mode")
}
@danalloway
danalloway / font-awesome.js
Created April 7, 2018 15:50
FontAwesome v5 Component I'm using with Preact
import { h, createElement } from 'preact'
import humps from 'humps'
import fontawesome from '@fortawesome/fontawesome'
// icons
import faClipboardList from '@fortawesome/fontawesome-pro-solid/faClipboardList'
import faPlus from '@fortawesome/fontawesome-pro-solid/faPlus'
fontawesome.library.add(faClipboardList, faPlus)
const Icon = props => {
@danalloway
danalloway / PersistGate.js
Created November 20, 2017 21:12
redux-persist PersistGate component for Preact
import { h, Component } from 'preact';
export default class PersistGate extends Component {
unsubscribe;
state = {
isBootstrapped: false
};
handlePersistorState = () => {
@danalloway
danalloway / app.js
Last active November 7, 2017 08:07
preact, redux, react-router-redux SSR
import { h } from 'preact';
import Link from 'react-router-dom/Link';
import Route from 'react-router-dom/Route';
import Switch from 'react-router-dom/Switch';
import Home from '../routes/Home';
import About from '../routes/About';
const App = () => (
<div>

Keybase proof

I hereby claim:

  • I am danalloway on github.
  • I am danalloway (https://keybase.io/danalloway) on keybase.
  • I have a public key ASCwi8A8WbtHO1dOgZmOJo4jdOcqjrSK5yBOQ05-xrNyGQo

To claim this, I am signing this object:

@danalloway
danalloway / 503.nginx
Created February 16, 2016 16:50
Custom NGINX 503 Page
server {
server_name _;
# override how 503's should be handled
error_page 503 @503;
location @503 {
# attempt to server our custom 503 first
# then fall back to the built-in one
try_files /503.html =503;