Skip to content

Instantly share code, notes, and snippets.

View ainsleyclark's full-sized avatar

Ainsley Clark ainsleyclark

View GitHub Profile
import { imageSizes } from '@ainsleydev/payload-helper/dist/collections/Media';
import env from '@ainsleydev/payload-helper/dist/util/env';
import { lexicalHTML } from '@payloadcms/richtext-lexical';
import * as mime from 'mime-types';
import { findBySource } from '@/collections/Media/endpoints/find-by-source';
import type { CollectionConfig, PayloadRequest } from 'payload';
export const Media: CollectionConfig = {
import { lexicalHTML } from '@payloadcms/richtext-lexical';
import { CollectionConfig, PayloadRequest } from 'payload';
import { mergeCentres } from '@/collections/Centres/endpoints/mergeCentres';
import { renameCentreField } from '@/collections/Centres/endpoints/rename';
import { actions } from '@/collections/Centres/fields/actions';
import { agencies } from '@/collections/Centres/fields/agencies';
import { capabilitiesGrouped } from '@/collections/Centres/fields/capabilities';
import { contact } from '@/collections/Centres/fields/contact';
import { diveDestinations } from '@/collections/Centres/fields/diveDestinations';
resource "digitalocean_database_cluster" "postgres" {
name = "db"
engine = "pg"
version = "17"
size = "db-s-1vcpu-1gb"
region = "lon1"
node_count = 1
}
resource "digitalocean_database_user" "postgres_app_user" {

Block:

import { Block } from "payload";
import { IdentifierField } from "@/fields/Identifer";

export const ProductsBlock: Block = {
	slug: 'products-block',
@ainsleyclark
ainsleyclark / sharp-images.ts
Created August 9, 2024 09:10
Digital Ocean Sharp Crashes
const sharp = require('sharp');
const fs = require('fs');
const path = require('path');
const imageSizes = [
// Original Size (for WebP & Avif)
{
name: 'original_webp',
width: undefined,
@ainsleyclark
ainsleyclark / Media.ts
Created August 8, 2024 17:32
Payload Media
import { lexicalEditor } from '@payloadcms/richtext-lexical';
import * as mime from 'mime-types';
import type { CollectionConfig, Field, PayloadRequest } from 'payload';
export const Media = (additionalFields?: Field[]): CollectionConfig => {
return {
slug: 'media',
access: {
read: () => true,
},
@ainsleyclark
ainsleyclark / wp-image.php
Created May 30, 2023 20:29
Alex - WP Imagery
<?php
/**
* Helpers
*
* A class for WordPress custom utility functions.
*
* @author Ainsley Clark
* @class Helpers
* @category Class
@ainsleyclark
ainsleyclark / enc.go
Last active December 5, 2022 12:09
Encryption
// DefaultCost is the cost that will actually be set if a
// cost below MinCost is passed into
// GenerateFromPassword.
var DefaultCost = bcrypt.DefaultCost
// HashPassword gets the password in byte format and
// generates a hashed password with the default cost
// of 10.
// Returns errors.INTERNAL if the bcrypt failed to generate from password.
func HashPassword(password string) (string, error) {
@ainsleyclark
ainsleyclark / page_update.go
Last active November 2, 2022 10:54
Mongo Page Update
const (
// DatabaseName is the database table name for Pages.
DatabaseName = "tasks"
// Collection is the collection in which scrapes
// and meta of a URL is stored.
Collection = "scrapes"
)
type ScrapeStore struct {
*mg.Database
@ainsleyclark
ainsleyclark / install.sh
Last active January 12, 2022 17:26
Mac Dev Install Script
#!/bin/bash
# Install brew
if ! hash brew
then
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
else
printf "\e[93m%s\e[m\n" "You already have brew installed."
fi