Skip to content

Instantly share code, notes, and snippets.

@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:
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: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
@chx
chx / gist:8206137
Last active January 1, 2016 21:49
How to find non-PSR0 classes
find path/to/dir -type f -name \*.php -exec awk -F ' ' '$1=="namespace" {namespace=substr($2, 1, length($2)-1); gsub("\\\\", "/", namespace);} /^(abstract|final)? *class/ {for (i=1;i<=NF;i++) if ($(i)=="class") namespaced=namespace "/" $(i+1) ; n = length(namespaced); if (namespaced != substr(FILENAME,length(FILENAME)-3-n,n)) print FILENAME " contains " namespaced } ' {} \;
@chx
chx / nato
Last active December 29, 2015 10:39
Dump anything with the nato spelling: save it in a file called nato, put in your PATH, chmod +x nato and then nato foobar will print: Foxtrot Oscar Oscar Bravo Alpha Romeo
#!/bin/bash
declare -A nato
nato[A]=Alpha
nato[B]=Bravo
nato[C]=Charlie
nato[D]=Delta
nato[E]=Echo
nato[F]=Foxtrot
nato[G]=Golf
nato[H]=Hotel
@chx
chx / gist:6626078
Last active December 23, 2015 11:09
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/chx/composer-913.git"
}
],
"require": {
"foo/bar": "v1"
}
@chx
chx / gist:5273370
Created March 29, 2013 20:22
add Definition support to YamlFileLoader::resolveServices
diff --git a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
index 71de4ac..ee9c589 100644
--- a/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+++ b/core/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
@@ -306,6 +306,8 @@ private function resolveServices($value)
}
$value = new Reference($value, $invalidBehavior, $strict);
+ } elseif (is_string($value) && 0 === strpos($value, '+')) {
+ $value = new Definition(substr($value, 1));
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
<testsuite name="Drupal Unit Test Suite" tests="1" assertions="0" failures="0" errors="1" time="0.002637">
<testsuite name="Drupal\Tests\Component\PhpStorage\FileStorageTest" file="/home/chx/www/system/core/tests/Drupal/Tests/Component/PhpStorage/FileStorageTest.php" namespace="Drupal\Tests\Component\PhpStorage" fullPackage="Drupal.Tests.Component.PhpStorage" tests="0" assertions="0" failures="0" errors="0" time="0.000000"/>
<testsuite name="Drupal\Tests\Component\PhpStorage\MTimeProtectedFastFileStorageTest" file="/home/chx/www/system/core/tests/Drupal/Tests/Component/PhpStorage/MTimeProtectedFastFileStorageTest.php" namespace="Drupal\Tests\Component\PhpStorage" fullPackage="Drupal.Tests.Component.PhpStorage" tests="0" assertions="0" failures="0" errors="0" time="0.000000"/>
<testsuite name="Drupal\Tests\Core\Cache\BackendChainImplementationUnitTest" file="/home/chx/www/system/core/tests/Drupal/Tests/Core/Cache/BackendChainImplementationUnitTe
while read -r project
do
output=`drush dl --dev -y -q --destination=allmodules --package-handler=git_drupalorg $project`
if [ -z "$output"]
then
output=`drush dl --dev -y -q --destination=allmodules --default-major=6 --package-handler=git_drupalorg $project`
if [ -z "$output"] ; then echo 'module sucks; fi
fi
done < allmodules.txt
@chx
chx / ConfigMetadata.php
Created December 19, 2012 10:08
Start of ConfigMetadata
<?php
namespace Drupal\Core\Config;
class ConfigMetadata {
/**
* @var \Drupal\Core\Config\Config
*/
protected $config;