Skip to content

Instantly share code, notes, and snippets.

View adrian-cid's full-sized avatar

Adrian Cid Almaguer adrian-cid

View GitHub Profile
@mglaman
mglaman / phpunit.xml
Last active June 15, 2023 13:38
My Drupal project phpunit.xml configuration
<?xml version="1.0" encoding="UTF-8"?>
<!-- TODO set checkForUnintentionallyCoveredCode="true" once https://www.drupal.org/node/2626832 is resolved. -->
<!-- PHPUnit expects functional tests to be run with either a privileged user
or your current system user. See core/tests/README.md and
https://www.drupal.org/node/2116263 for details.
-->
<phpunit bootstrap="web/core/tests/bootstrap.php" colors="true"
beStrictAboutTestsThatDoNotTestAnything="true"
beStrictAboutOutputDuringTests="true"
@webchick
webchick / most_wanted
Created September 20, 2017 08:19
Top 50 "most wanted" Drupal 8 contrib modules (by followers in the "contrib_tracker" project)
mysql> SELECT n.nid, n.title, c.count AS followers
-> FROM node n
-> INNER JOIN flag_counts c ON c.entity_id = n.nid
-> INNER JOIN field_data_field_project p ON p.entity_id = n.nid
-> INNER JOIN field_data_field_issue_status s ON s.entity_id = n.nid
-> WHERE p.field_project_target_id = 2573607 /* contrib_tracker */
-> AND s.field_issue_status_value NOT IN (2, 7, 3) /* fixed, closed (fixed), closed (duplicate) */
-> ORDER BY c.count DESC
-> LIMIT 50;
+---------+-----------------------------------------------------------+-----------+
@crittermike
crittermike / ExampleModuleController.php
Last active June 17, 2021 12:55
Example of overriding a route controller in Drupal 8
<?php
/**
* @file
* Contains \Drupal\example_module\Controller\ExampleModuleController.
*/
// THIS FILE BELONGS AT /example_module/src/Controller/ExampleModuleController.php
namespace Drupal\example_module\Controller;
@waako
waako / themename.theme.php
Last active June 17, 2019 12:54
Drupal 8: Get Block's parent Node title and full URL
<?php
use Drupal\Core\Url;
/**
* Implements hook_preprocess_HOOK() for block.html.twig.
*/
function themename_preprocess_block(&$variables) {
// Get Title of Block's parent Node.
$request = \Drupal::request();
@MartijnBraam
MartijnBraam / content-type-documentation.py
Created September 9, 2015 09:36
Generate content documentation using drush_entity
#!/usr/bin/env python3
"""
Use with: https://www.drupal.org/project/drush_entity
For example::
$ drush entity-type-read --format=json --include-fieldapi | content-type-documentation.py > documentation.md
"""
@facine
facine / __INDEX.txt
Last active August 6, 2023 15:33
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes:
@steve-todorov
steve-todorov / csv-to-array.php
Last active August 29, 2015 14:19
Get csv data as an array
<?php
set_time_limit(0);
ini_set('memory_limit',-1);
function parse_csv_assoc($str,&$f) {
if (empty($f)) { $f = str_getcsv($str); }
return @array_combine($f, str_getcsv($str));
}
@shsteimer
shsteimer / gist:7257245
Created October 31, 2013 21:10
Tip to delete tags by pattern
#delete all the remote tags with the pattern your looking for, ie. DEV-
git tag | grep <pattern> | xargs -n 1 -i% git push origin :refs/tags/%
#delete all your local tags
git tag | xargs -n 1 -i% git tag -d %
#fetch the remote tags which still remain
git fetch
@ozh
ozh / new empty git branch.md
Last active March 3, 2024 13:42
Create a new empty branch in Git
$ git checkout --orphan NEWBRANCH
$ git rm -rf .

--orphan creates a new branch, but it starts without any commit. After running the above command you are on a new branch "NEWBRANCH", and the first commit you create from this state will start a new history without any ancestry.

You can then start adding files and commit them and they will live in their own branch. If you take a look at the log, you will see that it is isolated from the original log.