Skip to content

Instantly share code, notes, and snippets.

View GregBrimble's full-sized avatar

Greg Brimble GregBrimble

View GitHub Profile
@GregBrimble
GregBrimble / README.md
Last active March 17, 2022 13:37
Force trailing slashes

Force Trailing Slashes

This example show how to force trailing slashes using a custom _worker.js file in your Cloudflare Pages project.

Usage

Copy the _worker.js file into your project's build output directory.

Behaviour

@GregBrimble
GregBrimble / image-test.tsx
Created September 27, 2021 09:41
Example of Cloudflare Images on Next.js (WIP)
import Image, { ImageLoader } from "next/image";
type Width = [string, number];
const widths = {
sm: 640,
md: 768,
lg: 1024,
xl: 1280,
};
addEventListener('fetch', (event) => {
event.respondWith(handleErrors(handleRequest, event.request))
})
const handleRequest = async (request) => {
const url = new URL(request.url)
switch (url.pathname) {
case '/': {
const newReleases = await spotify('/new-releases')
@GregBrimble
GregBrimble / archive.js
Last active March 4, 2021 10:45
A Cloudflare Workers proxy for Archive.org
addEventListener('fetch', event => {
event.respondWith(handleError(handleRequest, event.request))
})
class InvalidURLPathnameError extends Error {
constructor(pathname) {
super(`Invalid URL pathname: ${pathname}`)
this.name = "InvalidURLPathnameError"
}
}
$ wrangler publish
🌀  Using namespace for Workers Site "__scriptname-workers_sites_assets"
🌀  Uploading site files
✨  Success
⬇️ Installing wranglerjs...
⬇️ Installing wasm-pack...
✨  Built successfully, built project size is 241 KiB.
Error: Something went wrong! Status: 400 Bad Request, Details {
 "result": null,

Keybase proof

I hereby claim:

  • I am gregbrimble on github.
  • I am gregbrimble (https://keybase.io/gregbrimble) on keybase.
  • I have a public key ASDvJNoSSrRev8Vn1WFyDMWBbJ5yQLl1cpkLna-BnKSCjgo

To claim this, I am signing this object:

@GregBrimble
GregBrimble / id_rsa.pub
Created March 5, 2018 15:34
Greg Brimble's SSH public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCtm+POJtqnhn50Fprk36nJucsfw/qg7imvJKFK1+PC3Um4pwln58S7AzaqabmRTQpVHvQPyXUh0200BCDh5EL3kUKfdZ4umB+VsSE+mYGrhXNebYkeilp2TeZ+3XDCFD7u3m2G3buyM8GPGNDuwUoBhE0VqxZ7DzKR314+LDhphMptVQ1dN3up8PhxLrtO9bF3uMj8Kifv6dbBucCvWDYccnyW3/J3+vp/svYSXl1Ea6SL5EtlXQIyBGKosTqqAnxBVK1gAqhAMbBCYKoqajBJWBLz+S1Hc9Hf8ixvkCF9V8E6BGvIcWBo8Qj1NmUgpiyvwCjfPrWfqyw8vhtbr4M4N0K5LDPZs0dsTYfP6hcWakTKz9kivH0bBBDAouvZmriYsNPpkPl3nsMhH5pSXZRS4eb7ZKP1IyXq562MNCVy9mg+eNBH7l9CItjiEDd0z8NsBb8vMiVgstcONYirumlFj438PYtpHSeDtg0NhKF4EbFpFUnKCGrU2l9WbHZczTx1xapOkR9y8mXFgUGaUXYQknmTrgGxXgp+XBHAuZgEwESl9XaEejXnlq4JbdYc8GI2ii8cmrKs0RxCJICoZlbJe/iHnUdumi2XVqwyGLlQqPc7vYZyOvvuqRbkgiJKTCSL2s5P/nHpjWH1WTGw6ODcuO++bOPCqnKaW7OgdaFBAQ== developer@gregbrimble.com
@GregBrimble
GregBrimble / fix_ssh_permissions.sh
Last active March 11, 2018 11:57
SSH Permissions Fixer
echo "Hi, "$USER"! Welcome to the SSH permissions fixer."
echo "Fixing '~/.ssh' folder permissions..."
chmod -R 700 ~/.ssh
echo "Done."
echo "Fixing all keys (e.g. '~/.ssh/id_rsa') and their public components (e.g. '~/.ssh/id_rsa.pub')..."
chmod 600 ~/.ssh/* && chmod 644 ~/.ssh/*.pub
echo "Done."
@GregBrimble
GregBrimble / macOS.sh
Last active July 21, 2017 12:39
Setup script for a new MacOS machine
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap caskroom/cask
brew cask install google-chrome
brew cask install atom
apm install minimap file-icons todo-show
defaults write com.apple.dock static-only -bool TRUE; killall Dock
defaults write ~/Library/Preferences/.GlobalPreferences com.apple.swipescrolldirection -bool FALSE
git config --global user.name "Greg Brimble"
git config --global user.email developer@gregbrimble.com
git config --global core.editor atom