Skip to content

Instantly share code, notes, and snippets.

View garrett-green's full-sized avatar
💚

Garrett Green garrett-green

💚
View GitHub Profile
@perkinsjr
perkinsjr / middleware.ts
Last active January 31, 2024 11:06
Using Clerk with Upstash for Middleware rate limiting and API Protection
import { getAuth, withClerkMiddleware } from "@clerk/nextjs/server";
import { NextResponse, NextFetchEvent } from "next/server";
import type { NextRequest } from "next/server";
import { Ratelimit } from "@upstash/ratelimit";
import { Redis } from "@upstash/redis";
// Add public paths for Clerk to handle.
const publicPaths = ["/", "/sign-in*", "/sign-up*", "/api/blocked"];
// set your rate limit.
@progrium
progrium / README.md
Last active October 17, 2021 18:33
Large Type CLI utility for Mac in less than 80 lines of Go

largetype

largetype screenshot

Building

Note: For now, Apple Silicon users need to be set up for x86 mode

First, download Go or brew install go. Then, put largetype.go in a directory called largetype and from there run:

$ go mod init largetype
@james-a-rob
james-a-rob / meditation-scriptable.js
Created December 8, 2020 18:40
JS script written to help meditation. Run using the Scriptable IOS device.
const meditaionVideoData = {
morning: ['https://www.youtube.com/watch?v=wnusFbC0E80', 'https://www.youtube.com/watch?v=L-ecrmgzdGc', 'https://www.youtube.com/watch?v=fH3N7GTFDkw', 'https://www.youtube.com/watch?v=9Uk_w-r7zv4', 'https://www.youtube.com/watch?v=3RZ8n86CmJg', 'https://www.youtube.com/watch?v=xmKhN63yCPw&vl=en', 'https://www.youtube.com/watch?v=GneKaqMdKyk', 'https://www.youtube.com/watch?v=WYP_W49o1vQ', 'https://www.youtube.com/watch?v=-ZfC7FWjscc'],
day:['https://www.youtube.com/watch?v=ZToicYcHIOU'],
evening: ['https://www.youtube.com/watch?v=4jqGrF3Zqtg', "https://m.youtube.com/watch?v=aEqlQvczMJQ", "https://m.youtube.com/watch?v=bG3AcN-XOrw", "https://m.youtube.com/watch?v=qy8PKKwbjM0"]}
const ui = new UITable();
const row = new UITableRow()
const buttonRow = new UITableRow();
const button= buttonRow.addButton("MEDITATE NOW")

App Install Plan

Critical

import React from 'react';
class MicroFrontend extends React.Component {
componentDidMount() {
const { name, host, document } = this.props;
const scriptId = `micro-frontend-script-${name}`;
if (document.getElementById(scriptId)) {
this.renderMicroFrontend();
return;
@romixch
romixch / auth0-spa-js.tsx
Created February 5, 2020 21:33
Auth0: auth0-spa-js.js translated to Typescript
import React, { useState, useEffect, useContext, FC } from "react";
import createAuth0Client from "@auth0/auth0-spa-js";
interface Auth0ProviderProps {
children: JSX.Element;
auth0Options: Auth0ClientOptions;
onRedirectCallback: Function;
}
export interface Auth0ContextType {
@clairesrc
clairesrc / rebase
Last active September 9, 2019 14:54
Trunk Rebase Utility
#!/bin/bash
BASEBRANCH=${1:-master}
HEADBRANCH=`git rev-parse --abbrev-ref HEAD`
if [ "$BASEBRANCH" == "--help" ] || [ "$BASEBRANCH" == "-h" ];
then
echo "Usage: rebase BASEBRANCH (defaults to master)"
echo "Re-run the same command after fixing conflicts to reset upstream branch and push."
exit
fi
@aleccool213
aleccool213 / createResolver.ts
Last active November 21, 2019 14:34
A helper for apollo-local-state to create mutations much easier
import { IFieldResolver } from 'graphql-tools';
import { DocumentNode } from 'graphql';
import { ResolverContext } from '.';
interface InputVariablesShape<TInput> {
input: TInput;
}
/**
@garrett-green
garrett-green / export_google_music.js
Created March 28, 2019 20:15 — forked from jmiserez/export_google_music.js
(fixed/updated 2016-05-10) Export your Google Music Library and Playlists (Google Play Music All Access) (see http://webapps.stackexchange.com/questions/50311/print-playlist-from-google-play-music for more)
// Copyright 2016 Jeremie Miserez <jeremie@miserez.org>
//
// MIT License
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF O
@garrett-green
garrett-green / reactos.md
Created December 11, 2018 22:46 — forked from lotust/reactos.md
REACTO 1809-FSA-CH