Skip to content

Instantly share code, notes, and snippets.

@danalloway
danalloway / migrate-gcs-supabase.js
Last active May 12, 2021
Migrate Google Cloud Storage (GCS) to Supabase Storage
View migrate-gcs-supabase.js
/**
* 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 Apr 2, 2021
Supabase Storage - Upload Stream
View supabase_upload_stream.js
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 Feb 27, 2021
Remix v0.9.x & Tailwind v2.x
View global.css
/* ./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 Jul 9, 2019
React Providers using Context / State / Hooks
View ActivityProvider.js
/**
* 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([])
View hocClassBoilerplate.js
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 Apr 7, 2018
FontAwesome v5 Component I'm using with Preact
View font-awesome.js
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 Nov 20, 2017
redux-persist PersistGate component for Preact
View PersistGate.js
import { h, Component } from 'preact';
export default class PersistGate extends Component {
unsubscribe;
state = {
isBootstrapped: false
};
handlePersistorState = () => {
@danalloway
danalloway / app.js
Last active Nov 7, 2017
preact, redux, react-router-redux SSR
View app.js
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>
View keybase.md

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 Feb 16, 2016
Custom NGINX 503 Page
View 503.nginx
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;