Skip to content

Instantly share code, notes, and snippets.

View davidsonjames's full-sized avatar

James Davidson davidsonjames

View GitHub Profile
@davidsonjames
davidsonjames / card.html.twig
Created April 28, 2025 10:01
Example twig template
{#
Example component twig file: templates/components/card.html.twig
#}
<article class="card">
{% if image %}
<img src="{{ image }}" class="card__image" alt="{{ title }}">
{% endif %}
<div class="card__content">
<h2>{{ title }}</h2>
@davidsonjames
davidsonjames / ExampleBlock.php
Created October 5, 2020 13:26
Example Drupal PR Review
<?php
namespace Drupal\jd_example\Plugin\Block;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'ExampleBlock' block.
*
* @Block(
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
<?xml version="1.0"?>
<ruleset name="james">
<description>James Coding Standards</description>
<file>httpdocs/sites/all/modules/custom</file>
<file>httpdocs/sites/all/modules/features</file>
<file>httpdocs/sites/all/themes/custom</file>
<arg name="colors" />
<arg value="np"/>
<?php
// Logs a notice
\Drupal::logger('my_module')->notice($message);
// Logs an error
\Drupal::logger('my_module')->error($message);
?>
@davidsonjames
davidsonjames / sql_progress
Last active August 6, 2018 14:45
SQL Progess
pv sqlfile.sql | mysql -uxxx -pxxxx dbname