Skip to content

Instantly share code, notes, and snippets.

@miohtama
miohtama / sanitycheck.py
Created June 4, 2015 21:22
Perform database sync sanity check to SQLAlchemy models on application startup
import logging
from sqlalchemy import inspect
from sqlalchemy.ext.declarative.clsregistry import _ModuleMarker
from sqlalchemy.orm import RelationshipProperty
logger = logging.getLogger(__name__)
def is_sane_database(Base, session):
@MjHead
MjHead / jet-engine-metabox-from-code.php
Created February 26, 2020 08:31
Register custom meta box for JetEngine from code
<?php
add_action( 'jet-engine/meta-boxes/register-instances', 'my_register_meta_box' );
function my_register_meta_box( $meta_boxes_manager ) {
// Replace my_post_type_slug with your actual post type slug
$post_type = 'my_post_type_slug';
$object_name = $post_type . '_group';
function __prefix__add_relation_meta( $post_id, $meta_key, $related_posts = array() ) {
$relation = jet_engine()->relations->get_relation_info( $meta_key );
if ( ! $relation ) {
return;
}
if ( empty( $related_posts ) ) {
jet_engine()->relations->data->delete_all_related_meta( $meta_key, $post_id );
@wizard04wsu
wizard04wsu / fuzzySpoiler.htm
Last active June 20, 2023 01:41
CSS to obfuscate text until you hover over it. I got this idea from https://www.reddit.com/r/MumboJumboFanServer/ where similar CSS is used to hide spoilers.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CSS to obfuscate text</title>
<style>
@Crocoblock
Crocoblock / dynamic-field-custom-source.php
Created October 7, 2022 12:10
Add new Source to JetEngine Dynamic Field
<?php
class Dynamic_Filed_Source_Maybe_Unserialize {
public function __construct() {
add_filter( 'jet-engine/listings/dynamic-field/field-value', array( $this, 'process_value' ), 0, 2 );
add_filter( 'jet-engine/listings/data/sources', array( $this, 'add_source' ) );
}
public function process_value( $value, $settings ) {
@Crocoblock
Crocoblock / jet-engine-filter-repeater.php
Created January 23, 2023 15:38
JetEngine Filter repeater items before output
<?php
add_filter( 'jet-engine/listings/dynamic-repeater/pre-get-saved', function( $items, $settings ) {
$classes = $settings['_css_classes'] ?? '';
if ( ! $classes ) {
return false;
}
@Crocoblock
Crocoblock / register-options-page.php
Last active June 29, 2023 09:04
JetEngine Register Options page programmatically
<?php
add_action( 'init', 'register_my_custom_options_page', 20 );
function register_my_custom_options_page() {
$args = array (
'slug' => 'option-slug',
'labels' =>
array (
@Crocoblock
Crocoblock / add-meta-box.php
Last active June 29, 2023 09:07
JetEngine Register meta box for CPT/taxonomy/user programmatically
<?php
add_action( 'jet-engine/meta-boxes/register-instances', function( $meta ) {
//all field types are given for the reference, you can add any amount of fields of any type
$meta_fields = array (
array (
'title' => 'reference-text',
'name' => 'reference-text',
@SteveBarnett
SteveBarnett / notes.md
Last active October 6, 2023 01:45
OBS dual wield / dual video and audio

Send a second video using Full-screen Projector

  • Right click on the Preview, "Full-screen Projector (Preview)" menu item.
  • Choose the second screen from the list.

Send a second audio using Monitor

  • Go Settings > Audio. In Advanced, set the Monitoring Device to the second screen.
  • Go to Advanced Audio Properties (in the Audio mixer panel click the Cog, or the three dots button next to an audio source).
  • Choose "Monitor and Output" in the Audio Monitoring column for the correct audio source.
@Crocoblock
Crocoblock / register-relation.php
Last active December 8, 2023 08:22
JetEngine Relations: update items programmatically, register a relation programmatically
<?php
add_filter( 'jet-engine/relations/raw-relations', function( $relations ) {
$relations[999] = array(
'name' => 'User to post',
'parent_rel' => null,
'type' => 'many_to_many',
'is_legacy' => false,
'id' => 999,