Skip to content

Instantly share code, notes, and snippets.

Cameron Zemek grom358

Block or report user

Report or block grom358

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View function_replacer.php
#!/usr/bin/php
<?php
/**
* PHP Token
*/
class Token {
public $type;
public $text;
public $lineNo;
public $colNo;
@grom358
grom358 / array_syntax_convert.php
Created Apr 28, 2014
Convert from old array syntax array(...) to the new shorter array syntax [...]
View array_syntax_convert.php
<?php
require_once 'vendor/autoload.php';
// Import the Pharborist classes
use Pharborist\Filter;
use Pharborist\Node;
use Pharborist\Parser;
use Pharborist\TokenNode;
use Pharborist\TopNode;
View multi_search_node_access.php
<?php
/**
* Alters a multi search query to add node access checks.
*
* @param SearchApiMultiQueryInterface $query
* The executed search query.
*/
function hook_search_api_multi_query_alter(SearchApiMultiQueryInterface $query) {
global $user;
$indexes = $query->getIndexes();
View trace.php
<?php
function argToString($arg, $maxLength = false) {
if (is_null($arg)) {
return 'null';
} elseif (is_array($arg)) {
return 'Array';
} elseif (is_object($arg)) {
return 'Object(' . get_class($arg) . ')';
} elseif (is_bool($arg)) {
return $arg ? 'true' : 'false';
View cannon.js
"use strict";
/**
* High performance Vector library.
*
* Constructing vectors is expensive and therefore these functions take
* the required operands and a parameter to output the result into.
*/
var Vector = {};
View BrowserTestCase.php
<?php
use Behat\Mink\Mink;
use Behat\Mink\Selector\CssSelector;
use Behat\Mink\Session;
use Behat\Mink\Element\Element;
use Behat\Mink\Element\NodeElement;
abstract class BrowserTestCase extends PHPUnit_Framework_TestCase {
/**
View dep.php
<?php
class Dep {
protected $name;
protected $dependencies = [];
public function __construct($name) {
$this->name = $name;
}
@grom358
grom358 / generate_dep.php
Last active Aug 29, 2015
Generate dependency listing for install profile
View generate_dep.php
<?php
/**
* Root directory of Drupal installation.
*/
define('DRUPAL_ROOT', getcwd());
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
@grom358
grom358 / obj_to_array.php
Last active Aug 29, 2015
Convert PHP object to array
View obj_to_array.php
<?php
function object_to_array($data, $visited = array()) {
if (!is_array($data) and !is_object($data)) {
return $data;
}
if (is_object($data)) {
// Detect object cycles, overwise recursion occurs.
$hash = spl_object_hash($data);
if (isset($visited[$hash])) {
return '** RECURSION **';
@grom358
grom358 / indexer.md
Last active Aug 29, 2015
Index Features
View indexer.md
  • Query what source code files exist in the codebase
  • Query what classes/traits/interfaces exist. eg. $index->getClasses() returns fully qualified list of class names
  • Query what functions exist. eg. $index->getFunctions() returns fully qualified list of function names
  • On a class/trait/interface can find what methods/properties/constants exist
  • On a class/interface can inspect the parent class/interface
  • On a class/trait inspect what interfaces are implemented
  • For a class find subclasses
  • For a trait find trait usages
  • For an interface find class/traits that implement the interface
  • For an interface find interfaces which extend it
You can’t perform that action at this time.