Skip to content

Instantly share code, notes, and snippets.

View BrianJM's full-sized avatar

Brian BrianJM

  • 16:21 (UTC -04:00)
View GitHub Profile
@MarkAtOmniux
MarkAtOmniux / AddEditPhaseModal.tsx
Last active March 23, 2024 22:40
A Project Board Planner board built using Payload CMS
import React from 'react';
import { Modal } from '@faceless-ui/modal';
import { Button } from 'payload/components';
import {
Form,
FormSubmit,
RenderFields,
fieldTypes,
} from 'payload/components/forms';
const someQuestion: CollectionConfig = {
slug: 'some-collection',
custom: {
cacheControl: 'public, max-age=300, stale-while-revalidate=300, stale-if-error=86400',
},
}
@DrMint
DrMint / ExampleCollection.ts
Last active June 11, 2024 06:02
Grid View for Payload Uploads Collections
import { CollectionConfig } from "payload/types";
import { UploadsGridView } from "../../components/UploadsGridView/UploadsGridView";
export const Media: CollectionConfig = {
slug: "media",
admin: {
components: { views: { List: UploadsGridView } } // Set the List view to use the Grid view,
},
upload: {
staticURL: "/media",
import { User } from 'payload/dist/auth';
import { Access, AccessArgs, FieldAccess } from 'payload/types';
type CheckerArgs = {
user?: User;
id?: string | number;
};
type Checker = (args: CheckerArgs) => boolean;
const isAdmin: Checker = ({ user }) => user?.role && user?.role === 'admin';
@Explosion-Scratch
Explosion-Scratch / Compress string.js
Created November 1, 2021 18:51
Compress string using gzip and native browser APIs
function compress(string, encoding) {
const byteArray = new TextEncoder().encode(string);
const cs = new CompressionStream(encoding);
const writer = cs.writable.getWriter();
writer.write(byteArray);
writer.close();
return new Response(cs.readable).arrayBuffer();
}
function decompress(byteArray, encoding) {
@muhammad-owais-javed
muhammad-owais-javed / OS-GreymonSheet.sh
Last active July 15, 2024 01:41
Scripts, Commands, Configurations, Package Deployments and Apache .htaccess rules particularly as per Cloudways stack
#OS-GreymonSheet
#For switching to Master user
for user in $(cat /etc/passwd | grep master | awk -F : '{print $1}'); do su $user; done
#For Finding application with corresponging domain name
grep -lr "domain.com" */conf/*
#For checking apache logs of every application in Cloudways
@muhammad-owais-javed
muhammad-owais-javed / MySQL_Sheet.sh
Created August 1, 2021 20:21
Useful MySQL queries and configurations
#MYSQL
#For login to mysql
mysql -h hostname -u dbusername -p dbname
#For taking dump of mysql
mysqldump -h hostname -u dbusername -p dbname > dbbackup.sql
#For taking dump without tablespaces
mysqldump -h hostname -u dbusername -p dbname --no-tablespaces > dbback.sql
#Wordpress Sheet
#For verifying Core wordpress files
wp core verify-checksums
#For restricting auto update of wordpress
define( 'WP_AUTO_UPDATE_CORE', false );
#For increasing memory limit
define('WP_MEMORY_LIMIT', '256M');
@maxkostinevich
maxkostinevich / index.html
Last active July 23, 2024 12:00
Cloudflare Worker - Handle Contact Form
<!--
/*
* Serverless contact form handler for Cloudflare Workers.
* Emails are sent via Mailgun.
*
* Learn more at https://maxkostinevich.com/blog/serverless-contact-form
* Live demo: https://codesandbox.io/s/serverless-contact-form-example-x0neb
*
* (c) Max Kostinevich / https://maxkostinevich.com
*/
@jamilnyc
jamilnyc / thumbnail.js
Created July 23, 2016 03:55
Create a thumbnail from a PDF in Node
var gm = require('gm');
// Create JPG from page 0 of the PDF
gm("file.pdf[0]") // The name of your pdf
.setFormat("jpg")
.resize(200) // Resize to fixed 200px width, maintaining aspect ratio
.quality(75) // Quality from 0 to 100
.write("/tmp/cover.jpg", function(error){
// Callback function executed when finished
if (!error) {