Skip to content

Instantly share code, notes, and snippets.

@chx
chx / gist:11069092
Last active August 29, 2015 14:00
Create a list of blocks used by context.module
ag -l -G 'context.inc$' blocks |xargs grep -h -B1 delta |awk 'BEGIN { RS = "--"; FS="\n" } /=>/ { print $2 $3 }' |sort|uniq >block_list.txt
function git() {
# Path to the `git` binary
GIT="/usr/bin/git"
# Sanity check
if [ ! -f ${GIT} ]
then
echo "Error: git binary not found" >&2
return 255
fi
@chx
chx / gist:24b4ad4fe570c5b534b0
Last active August 29, 2015 14:13
keybase.md
### Keybase proof
I hereby claim:
* I am chx on github.
* I am chx (https://keybase.io/chx) on keybase.
* I have a public key whose fingerprint is E8E8 29B3 83DB 433C 7C54 E763 B80D EEC8 A487 BE88
To claim this, I am signing this object:
@chx
chx / Drupal 8 HEAD
Created February 28, 2015 05:57
Refactoring fun with benjy
public function next() {
$this->currentIds = NULL;
$this->currentRow = NULL;
$source_configuration = $this->migration->get('source');
while ($this->getIterator()->valid()) {
$row_data = $this->getIterator()->current() + $source_configuration;
$this->getIterator()->next();
$row = new Row($row_data, $this->migration->getSourcePlugin()->getIds(), $this->migration->get('destinationIds'));
@chx
chx / gist:3612ac536e195f93dc02
Last active August 29, 2015 14:18
Get translatable entity menu paths
SELECT path
FROM menu_router
WHERE load_functions IN
(SELECT DISTINCT concat('a:1:{i:1;s:', length(concat(entity_type, '_load')), ':"', entity_type, '_load";}')
FROM field_config fc
INNER JOIN field_config_instance fci ON fci.field_id=fc.id
WHERE fc.active=1 AND fc.translatable=1)
AND path NOT LIKE '%/%/%';
@chx
chx / gist:2e0a392499843cdd9df5
Created April 20, 2015 18:49
"$err" : "Runner error: BadValue cannot sort with keys that are parallel arrays",
> db.test.drop();
true
> db.test.insert({f1:[1],f2:[1]});
WriteResult({ "nInserted" : 1 })
> db.test.find().sort({'f1':1,'f2':1});
error: {
"$err" : "Runner error: BadValue cannot sort with keys that are parallel arrays",
"code" : 17144
}
@chx
chx / gist:7f6baf855dd1f8be5f21
Last active August 29, 2015 14:20
States to taxonomy IDs
<?php
/**
* @file
* Contains \Drupal\migrate_plus\Plugin\migrate\process\TermReference.
*/
namespace Drupal\migrate_plus\Plugin\migrate\process;
use Drupal\taxonomy\TermStorageInterface;
@chx
chx / patch
Last active August 29, 2015 14:23
<?php
/**
* @file
* Contains \Drupal\Core\StreamWrapper\FileDatabaseStream.
*/
namespace Drupal\Core\StreamWrapper;
use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
@chx
chx / test.php
Created March 26, 2012 22:56
drupal_render - twig integration
<?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/Twig/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
// Almost empty class, just swaps Twig_Node_Print objects to Drupal_Twig_Node_Print objects.
class Drupal_Twig_NodeVisitor implements Twig_NodeVisitorInterface {
function enterNode(Twig_NodeInterface $node, Twig_Environment $env) {
@chx
chx / gist:2861969
Created June 3, 2012 04:55
config presave
function presave() {
module_invoke_all('config_presave', $this);
$hook = 'config_presave';
$part = strtok($this->name, '.');
do {
$hook .= '_' . $part;
module_invoke_all($hook, $this);
} while ($part = strtok('.'));
}