Skip to content

Instantly share code, notes, and snippets.

@spivurno
spivurno / sse.php
Created June 5, 2023 13:16 — forked from jordymeow/sse.php
SSE (Server-Sent Events) with PHP and JS / Streaming with PHP
<?php
// Various links
// https://serverfault.com/questions/488767/how-do-i-enable-php-s-flush-with-nginxphp-fpm
// https://stackoverflow.com/questions/72394213/nginx-configuration-for-server-sent-event
// https://serverfault.com/questions/801628/for-server-sent-events-sse-what-nginx-proxy-configuration-is-appropriate
// https://qiita.com/okumurakengo/items/cbe6b3717b95944083a1 (in Japanese)
// If '?SSE' is set, send Server-Sent events, otherwise we'll display the page.
if ( isset( $_GET['SSE'] ) ) {
@spivurno
spivurno / how-i-work-template.md
Created June 14, 2023 13:46 — forked from jazzsequence/how-i-work-template.md
Template for How I Like to Work posts

How I work

This is my own interpretation of how I like to work, feedback welcome! Especially if my own view of how I think I like to work doesn't match your experience of how it seems I like to work!

When I work

<?php
add_filter('gpeb_filters_col_rows_query', 'custom_optimize_gf_entry_meta_query_with_cache', 10, 3);
function custom_optimize_gf_entry_meta_query_with_cache($sql, $col, $table) {
// Check if the current table and column are the ones we want to optimize
if ($table === GFFormsModel::get_entry_meta_table_name() && $col === 'meta_key') {
// Attempt to retrieve cached meta_key results
$cached_meta_keys = get_transient('gf_entry_meta_keys');
// If the cache exists, skip running the query