Skip to content

Instantly share code, notes, and snippets.

View lightningspirit's full-sized avatar
🏠
Working from home

Vitor Carvalho lightningspirit

🏠
Working from home
View GitHub Profile
@lightningspirit
lightningspirit / distributed-event-system.ts
Created April 29, 2022 16:55
A distributed event system for Node.js using Redis as storage system
import { createClient } from "redis"
type Listener = <E extends Event>(event: E) => void
/**
* Atomic distributed memory accross nodes
* backed by Redis server.
*/
class DistributedMemory {
/**
@lightningspirit
lightningspirit / contentdb.ts
Created April 29, 2022 16:54
ContentDB - A tiny JS cache-in-disk database for embeddable systems
import { promises as fs } from "fs"
import path from "path"
export interface NodeItem {
id: string
data: any
}
const cache: NodeItem[] = []
@lightningspirit
lightningspirit / elementor-s3-uploads.php
Created February 24, 2022 13:28
Some WordPress Mu-plugins
<?php
/**
* Plugin Name: Elementor S3
* Description: Elementor support for S3 Uploads plugins
* Plugin URI: https://gist.github.com/lightningspirit/73df703f0db1fef14bd30d64ea1e8631
* Author: Move Your Digital, Inc.
* Author URI: https://moveyourdigital.com
* Version: 0.1.0
*
@lightningspirit
lightningspirit / README.md
Created February 17, 2022 21:46
Disable WordPress Admin Bar MU-Plugin

Disable WordPress Admin Bar MU-Plugin

Disable the admin bar for all users automatically.

Usage

  1. Download or copy the disable-admin-bar.php file
  2. Place it under wp-content/mu-plugins
  3. Done
@lightningspirit
lightningspirit / README.md
Last active July 7, 2022 11:17
WordPress Autoload Composer Vendor MU-Plugin

WordPress composer autoload

Do you use WordPress along with composer? This is the right plugin for you. Just add it to mu-plugins and the root autoloader is activated.

Usage

  1. Download or copy the autoload.php file
  2. Place it under wp-content/mu-plugins
  3. Done
@lightningspirit
lightningspirit / README.md
Last active December 12, 2023 03:03
WordPress Multisite Network Plugin management

WordPress Multisite Network Plugin management

For multisite network ONLY Adds a new Plugins tab under wp-admin/network/sites.php which gives the ability to enable or disable (without actually activate) plugins per site.

This just "hides" not enabled plugins from the site plugins area.

Note: the super-admin can still have access to all plugins, even for each specific website which is great because the super-admin can activate hidden plugins :-)

@lightningspirit
lightningspirit / README.md
Last active May 30, 2022 19:27
WordPress SMTP MU-Plugin with support for multisite network

WordPress SMTP MU-Plugin

Configure SMTP with constants or site options with support for multisite networks.

Usage

  1. Just download or copy this file
  2. Place it under wp-content/mu-plugins/smtp-emails.php
  3. Done.
@lightningspirit
lightningspirit / cc.ts
Created February 4, 2022 18:51
ClassCat like function but simpler and smaller
function classNames(...classes: (boolean | string | string[])[]) {
return classes
.flatMap((v) => v)
.filter(Boolean)
.join(" ")
}
@lightningspirit
lightningspirit / omit.ts
Created January 28, 2022 00:30
TypeScript Omit function
interface Omit {
<T extends Record<string, any>, K extends [...(keyof T)[]]>(
obj: T,
...keys: K
): {
[K2 in Exclude<keyof T, K[number]>]: T[K2]
}
}
const omit: Omit = (obj, ...props) => {
@lightningspirit
lightningspirit / info.json
Created August 17, 2021 10:07
WpPluginRepositoryTestCase
{
"name": "my-plugin-test"
}