Skip to content

Instantly share code, notes, and snippets.

@dawehner
dawehner / Test.json
Last active July 31, 2016 09:07 — forked from anonymous/Test.json
JSON Decoder
[
{
"typeID":35,
"regionID":10000011,
"orders":[
{
"volRemaining":95050881,
"volEntered":100000000,
"range":32767,
"price":3.03,
<?php
namespace Drupal\Component\Utility;
/**
* Builds an array of strings for printing.
*/
class StringBuilder {
use ToStringTrait;
@dawehner
dawehner / hack.sh
Last active August 29, 2015 08:52 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
  • rss.xml - single purpose path responding with a content type
  • node/1.json - multipurpose path with an extension denoting content type.
  • myalias.json - an alias with and extension.
  • admin/foo/example.plugin_id - An arbitrary path containing some placeholder
  • rest/node/1 - a non-web endpoint doing full conneg
@dawehner
dawehner / gist:6612021
Last active December 23, 2015 09:09 — forked from anonymous/gist:6611959
/**
* Implements hook_views_data_alter().
*/
function feature_user_views_data_alter(&$data) {
// Actions
$data['users']['profession'] = array(
'title' => t('Profession'),
'help' => t('Profession of a user'),
'field' => array(
$times = array();
for ($i = 0; $i <= 10; $i++) {
$view = views_get_view('frontpage');
for ($j = 0; $j <= 100; $j++) {
$view->setDisplay('page_1');
$view->execute();
$start = microtime();
$view->destroy();
function asin_field_views_data($field) {
$data = field_views_field_default_views_data($field);
foreach ($data as $table_name => $table_data) {
foreach ($table_data as $field_name => $field_data) {
// Check for fieldapi value fields.
if (isset($field_data['filter']['field_name'])) {
$data[$table_name][$field_name]['relationship'] = array(
'handler' => 'views_handler_relationship',
'base' => 'amazon_item',
<?php
//$Id$
class content_moderation_handler_filter_pending_revision extends views_handler_filter {
function construct() {
parent::construct();
$this->additional_fields['node_vid'] = array('table' => 'node', 'field' => 'vid');
$this->additional_fields['revision_vid'] = array('table' => 'node_revision', 'field' => 'vid');
}