Skip to content

Instantly share code, notes, and snippets.

@ker0x
ker0x / find_by_role.php
Last active October 10, 2022 16:01
Symfony User findByRole
<?php
public function findByRole(Role $role): mixed
{
$rsm = $this->createResultSetMappingBuilder('u');
$query = <<<SQL
SELECT %s
FROM user u
WHERE u.roles::jsonb ?? :role
<?php
/**
* Settings class
*/
/**
* Class Settings
*/
class Settings {
/**
@19h47
19h47 / queries.sql
Last active December 10, 2019 10:55
SQL queries to change domain name on a WordPress site
# see https://sql.sh/988-requetes-migrer-wordpress
# Change the URL of the site
UPDATE wp_options
SET option_value = replace(option_value, 'http://localhost:8888/site', 'http://www.site.fr')
WHERE option_name = 'home'
OR option_name = 'siteurl';
# Change GUID URL
UPDATE wp_posts
@josanua
josanua / wp-code-utils.php
Last active April 16, 2024 12:49
wp code utils
<?php
************ Debug, Debuging ************
//Activate log files in wp-config.php
define( 'WP_DEBUG', true ); // Enabling WP_DEBUG will cause all PHP errors, notices and warnings to be displayed.
define( 'WP_DEBUG_LOG', true ); // Enable Debug logging to the /wp-content/debug.log file
define( 'WP_DEBUG_DISPLAY', true ); // Controls whether debug messages are shown inside the HTML of pages or not.
// use this
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
@honnoretsu
honnoretsu / notification.tag.html
Last active September 18, 2017 09:06
RiotJS basic notification tag through observables
<notification>
<div id="snackbar"></div>
<script>
/* USAGE:
create an observable:
var globalEvents = riot.observable();
And pull the trigger anywhere you need to:
globalEvents.trigger('notif_trigger', "Action done successfully");
*/
globalEvents.on('notif_trigger', function(data){
@damusix
damusix / app.js
Last active December 6, 2018 14:27
RiotJS Global Store
// Originally, I was using Redux to contain the state, but switched to RiotControl
// because of its simplicity, and how it makes use of Riot's observable API.
// An issue I found with RiotControl was that, when you register multiple
// stores, it will call 1 event 1 time per store. So if you have 6 stores,
// `RiotControl.trigger('my-event')` will run 6 times. This is incredibly
// inefficient, especially if your app is doing a lot at once.
// After careful consideration, I failed to see the benefit of using
// RiotControl and instead opted for using the native Riot observable API.
@AS87-code
AS87-code / Bootstrap slider
Last active November 18, 2017 14:01
WordPress
<div id="myCarousel" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#myCarousel" data-slide-to="0" class="active"></li>
<li data-target="#myCarousel" data-slide-to="1"></li>
<li data-target="#myCarousel" data-slide-to="2"></li>
</ol>
<div class="carousel-inner" role="listbox">
<?php query_posts( 'meta_key=slide&showposts=3' ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!--HTML-->
<div class='images' id='image1'>
<div class='layer'></div>
<img src='images/picture.jpg' alt="" width="200" height="200" border="0" />
</div>
<div class='images' id='image2'>
<div class='layer'></div>
<img src='images/picture.jpg' alt="" width="200" height="200" border="0" />
</div>
<div class='images' id='image3'>
@danburzo
danburzo / README.md
Last active July 29, 2021 08:41
Get all event listeners on the page in Google Chrome