Skip to content

Instantly share code, notes, and snippets.

View joelpittet's full-sized avatar

Joel Pittet joelpittet

View GitHub Profile
function get_property_1_listings() {
$args = array('post_type' => 'listing');
$loop = new WP_Query($args);
$content = '<ul class="listings">';
$count = 0;
while ($loop->have_posts()) {
$loop->the_post();
$address = get_field('address');
if ($address == 'Property 1') {
$count++;
SELECT u.uid, u.name, u.mail as email, u.status,
EXISTS (
SELECT n.nid nid, NULL as uid FROM node n
WHERE n.type = 'manual' AND n.status = 1 AND nid NOT IN (
SELECT fc.content_id nid FROM flag_content as fc
RIGHT JOIN node n ON (fc.content_type = 'node' AND fc.fid = 3
AND fc.content_id = n.nid AND n.type = 'manual' AND n.status = 1)
WHERE fc.uid = u.uid
)
) as read_manuals
<?php
// At top of template_preprocess_table function for test
$colgroups = array(
// COLGROUP with one COL element.
array(
'data' => array(
array(
'class' => array('test1-1'), // Attribute for the COL element.
),
@joelpittet
joelpittet / gist:4948311
Created February 13, 2013 21:10
SEO domain redirect and save the W key
# Make sure the domain always removes the www
RewriteCond %{HTTP_HOST} ^www\.pittet\.ca$
RewriteRule (.*) http://pittet.ca/$1 [R=301,L]
@joelpittet
joelpittet / gist:5164471
Last active December 14, 2015 23:19
Menu Overview type table conversion
<?php
$form['links'] = array(
'#type' => 'table',
'#attributes' => array('id' => 'menu-overview'),
'#header' => array(
t('Menu link'),
array('data' => t('Enabled'), 'class' => array('checkbox')),
t('Weight'),
t('Operations'),
@joelpittet
joelpittet / gist:5379755
Last active December 16, 2015 04:48
Render array from test
<?php
array (
0 => array(
'label' => 'Drupal core',
'projects' => array(
'drupal' => array(
'attributes' =>
Drupal\Core\Template\Attribute::__set_state(array(
'storage' => array(
Warning: Must specify directory location for XHProf runs. Trying /tmp as default. You can either pass the directory location as an argument to the constructor for XHProfRuns_Default() or set xhprof.output_dir ini param.
=== 8.x..8.x compared (5198078e48bc9..519807e737082):
ct : 37,804|37,806|2|0.0%
wt : 284,085|277,540|-6,545|-2.3%
cpu : 253,007|248,977|-4,030|-1.6%
mu : 11,494,656|11,494,656|0|0.0%
pmu : 11,669,976|11,669,976|0|0.0%
<a href="http://d8prof.dev/xhprof-kit/xhprof/xhprof_html/index.php?source=drupal-perf&url=%2F&run1=5198078e48bc9&run2=519807e737082&extra=8.x..8.x">Profiler output</a>
# aggregator/sources/1
# BBC Feeds 82 articles, 20 per page shown.
$ bbranches 5198078e48bc9 1896060-twig-aggregator
=== 8.x..8.x compared (5198078e48bc9..519807e737082):
ct : 37,804|37,806|2|0.0%
wt : 284,085|277,540|-6,545|-2.3%
cpu : 253,007|248,977|-4,030|-1.6%
mu : 11,494,656|11,494,656|0|0.0%
# aggregator/sources/1
# BBC Feeds 82 articles, 20 per page shown.
[ 8.x ] $ bbranches 51981a3a6232a 1896060-twig-aggregator
=== 8.x..8.x compared (51981a3a6232a..51981a807e11e):
ct : 38,281|38,281|0|0.0%
wt : 278,813|278,935|122|0.0%
cpu : 249,691|250,819|1,128|0.5%
@joelpittet
joelpittet / xhprof-kit.sh
Created May 22, 2013 21:37
xhprof-kit aliases and functions
# Creates a baseline from your 8.x branch.
alias bbranch='./xhprof-kit/benchmark-branch.sh `git rev-parse --abbrev-ref HEAD`'
# Using the baseline xhprof identifier from the bbranch command above will benchmark 8.x against the baseline and your patched branch.
# e.g.
# bbranches [XHPROF-IDENTIFIED] [twig-branch-name-here-1234456]
function bbranches() {
originalbranch="$(git rev-parse --abbrev-ref HEAD)"
base=$1
shift