Skip to content

Instantly share code, notes, and snippets.

@hervehobbes
hervehobbes / .github-workflows-main.yaml
Created September 13, 2021 05:51 — forked from mathieu-coingt/.github-workflows-main.yaml
Github Actions Workflow for Symfony project
name: CI/CD production
on:
push:
branches: [ production ]
jobs:
build:
runs-on: ubuntu-latest
steps:
# Mandatory : fetch the current repository
@georgestephanis
georgestephanis / client.js
Last active June 2, 2024 23:54
This is an example client app to integrate with the WordPress 5.6 Application Passwords system. It walks the user through authenticating, and then queries and enumerates all users on the site.
(function($){
const $root = $( '#root' );
const $stage1 = $( '.stage-1', $root );
const $stage2 = $( '.stage-2', $root );
// If there's no GET string, then no credentials have been passed back. Let's get them.
if ( ! window.location.href.includes('?') ) {
// Stage 1: Get the WordPress Site URL, Validate the REST API, and Send to the Authentication Flow
const $urlInput = $( 'input[type=url]', $stage1 );
@byevhen2
byevhen2 / apiRequest.js
Last active May 16, 2025 18:59 — forked from phpbits/apiRequest.js
Using wp.apiRequest to access custom endpoints.
// See: wp-includes/js/api-request.js
// Returns a jqXHR object. See: https://api.jquery.com/jQuery.ajax/#jqXHR
wp.apiRequest({path: '/namespace/vendor/v1/config'})
.then(configOptions => console.log(configOptions));
// jqXHR object has method then(), but does not have methods catch() or
// finally(). Use fail() or always() instead
wp.apiRequest({path: '/namespace/vendor/v1/config'})
.done(configOptions => console.log(configOptions))
@keithrozario
keithrozario / on_delete.yml
Last active July 26, 2024 21:15
Get branch name on branch delete github actions
name: Serverless Delete example
on:
delete:
branches:
- actions-**
# Specify what jobs to run
jobs:
deploy:
@bfintal
bfintal / cheatsheet.js
Last active June 28, 2025 01:10
Gutenberg Cheat Sheet
// Get the data of a block
wp.data.select( 'core/block-editor' ).getBlocks()[0]
// Update attributes of another block
// wp.data.dispatch( 'core/editor' ).updateBlockAttributes( clientID, attributes )
wp.data.dispatch( 'core/block-editor' ).updateBlockAttributes( '10d88a6d-95d6-4e07-8293-5f59c83a26c0', { heading: 'New Heading' } )
// Get currently selected block.
wp.data.select( 'core/block-editor' ).getBlockSelectionStart()
@thatdevgirl
thatdevgirl / simple-autocomplete.js
Created November 29, 2018 15:29
Simple Autocomplete component for WP Gutenberg
/**
* A very simple autocomplete component
*
* This is to replace the OOTB Gutenberg Autocomplete component because it is
* currently broken as of v4.5.1.
*
* See Github issue: https://github.com/WordPress/gutenberg/issues/10542
*
* Note: The options array should be an array of objects containing labels and values; i.e.:
* [
@dac514
dac514 / EventEmitter.php
Last active July 22, 2025 01:42
Refactor Your Slow Form Using PHP Generators and Event Streams
<?php
/**
* @license GPLv3 (or any later version)
* @see http://kizu514.com/blog/refactor-your-slow-form-using-php-generators-and-event-streams/
*/
namespace KIZU514;
class EventEmitter
{
@marlenesco
marlenesco / Entity-vs-Model.md
Last active October 8, 2022 22:41
Terminology in Symfony and Doctrine. Record vs Entity vs Document vs Model

I was just asked to write a small summary about the difference between a model and an entity. As I am too lazy to think up another topic for today I will just jump on that. And actually I wrote about this before as it can be quite irritating to see model folders in some bundles and entity folders in others. So what is what?

Before Doctrine 2.0 we were used to the ActiveRecord pattern in the symfony world. So let’s start from there.

The Record

is an object representation of a thing in the real world. It has some attributes that the real thing has as well (i.e. age, size, color, ..) and some methods the real thing can perform as well (i.e. walk, run, bark, ..).

The record in an ActiveRecord pattern also knows how to be persisted as it has a save() method and some other persistence related functionalities. To avoid duplicated code all this persistence code is written in a generic way and inherited by all record classes.

@swalkinshaw
swalkinshaw / tutorial.md
Last active July 20, 2025 07:39
Designing a GraphQL API