Skip to content

Instantly share code, notes, and snippets.

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 / gist:97fc107ee2a968628636
Last active January 22, 2016 15:23 — forked from edysmp/gist:24f0a13c3d4834dbe514
lookupDestinationId
// When looking up the destination ID we require an array with both the
// source key and value, e.g. ['nid' => 41]. In this case, $source_id_values need to be ordered the same
// order as $this->sourceIdFields(). However, the Migration process
// plugin doesn't currently have a way to get the source key so we presume
// the values have been passed through in the correct order.
if (!isset($source_id_values[0])) {
$source_id_values = array_intersect_key($this->sourceIdFields(), $source_id_values);
}
sudo composer self-update
Updating to version 02ed27b16b184ecd6befed5bf8f6501084b42c0e.
Downloading: 100%
Use composer self-update --rollback to return to version 1.0.0-alpha11
➜ d8 git:(8.0.x) ✗ time composer require drupal/page_manager
You are running composer with xdebug enabled. This has a major impact on runtime performance. See https://getcomposer.org/xdebug
^C
composer require drupal/page_manager 0.54s user 0.05s system 15% cpu 3.756 total
➜ d8 git:(8.0.x) ✗ sudo nano /etc/php/php.ini
➜ d8 git:(8.0.x) ✗
[4.6MB/0.01s] Reading ./composer.json
[4.7MB/0.01s] Loading config file /home/chx/.composer/config.json
[4.7MB/0.01s] Loading config file /home/chx/.composer/auth.json
[4.7MB/0.01s] Loading config file ./composer.json
[5.0MB/0.02s] Checking CA file /etc/ca-certificates/extracted/tls-ca-bundle.pem
[5.6MB/0.02s] Executing command (/tmp/d8): git branch --no-color --no-abbrev -v
[7.4MB/0.05s] Reading /home/chx/.composer/composer.json
[7.4MB/0.05s] Loading config file /home/chx/.composer/config.json
[7.4MB/0.05s] Loading config file /home/chx/.composer/auth.json
[7.4MB/0.05s] Loading config file /home/chx/.composer/composer.json