Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Mateu Aguiló Bosch e0ipso

🏠
Working from home
View GitHub Profile
View better-than-ericduran.zsh-theme
# Based on the agnoster's Theme (https://gist.github.com/3712874)
# With some a couple of small changes.
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://gist.github.com/1595572).
### Segment drawing
# A few utility functions to make it easy and re-usable to draw segmented prompts
CURRENT_BG='NONE'
@e0ipso
e0ipso / multifield-features.patch
Created Oct 13, 2014
Multifield features patch
View multifield-features.patch
diff --git a/multifield.features.inc b/multifield.features.inc
index ca7a8ab..152ebc1 100644
--- a/multifield.features.inc
+++ b/multifield.features.inc
@@ -30,3 +30,29 @@ function multifield_features_pipe_field_base_alter(&$pipe, $data, $export) {
}
}
}
+
+/**
@e0ipso
e0ipso / local_update.drush.inc.php
Last active Aug 29, 2015
Drupal local update. Update your local database based on a remote environment.
View local_update.drush.inc.php
<?php
/**
* Implementation of hook_drush_command().
*/
function local_update_drush_command() {
$items = array();
$items['local-update'] = array(
'description' => 'Downloads a dump of the remote database, suffixes that file with the current date and stores it in the selected location. After importing the database, it will run update hooks, revert all features, and clear cache. Once all this is finished, if everything is installed, the bundle command to rebuild all css will be run.',
View generate_personal.sh
#!/bin/bash
cat <<EOF > /tmp/personal.json
{
"git": {
"user": {
"name": "Enter your name",
"email": "your@email.sex"
},
"core": {
"editor": "vi"
@e0ipso
e0ipso / controller-pattern.php
Last active Aug 29, 2015
Accessors and mutators
View controller-pattern.php
<?php
class MyController extends ControllerBase implements ControllerInterface {
/**
* @var MyClass1
* Object of Class 1
*/
protected $obj1;
@e0ipso
e0ipso / rest-performance
Last active Aug 29, 2015
REST modules performance comparison.
View rest-performance
# Varnish caching
## List of 300 items
Requests per second: 6717.35 [#/sec] (mean) # RESTful Memcache render cache.
Requests per second: 7096.14 [#/sec] (mean) # RESTful Database render cache.
Requests per second: 6379.45 [#/sec] (mean) # RESTful No render cache.
Requests per second: 95.24 [#/sec] (mean) # RESTWS
Requests per second: 1125.62 [#/sec] (mean) # Services
## List of 50 items
Requests per second: 6632.03 [#/sec] (mean) # RESTful Memcache render cache.
Requests per second: 7057.74 [#/sec] (mean) # RESTful Database render cache.
@e0ipso
e0ipso / DataProvider.php
Last active Aug 29, 2015
RESTful 7.x-2.x - Mocks
View DataProvider.php
// Declares the CRUD operations (including the request parsing for filters, fields, sorts, …)
// Composed by a swappable DataResource.
@e0ipso
e0ipso / comparison.php
Created Feb 16, 2015
isset & array_key_exists
View comparison.php
<?php
$array = array(
'foo' => 'bar',
'baz' => NULL,
);
print 'isset: ' . (isset($array['baz']) ? 'True' : 'False') . PHP_EOL;
print 'array_key_exists: ' . (array_key_exists('baz', $array) ? 'True' : 'False') . PHP_EOL;
@e0ipso
e0ipso / array_key_exists.php
Last active Aug 29, 2015
empty vs array_key_exists
View array_key_exists.php
<?php
define('ITERATIONS', 10000000);
$array = array(
'foo' => 'bar',
'baz' => 'zzz',
);
for ($i = 0; $i < ITERATIONS; $i++) {
@e0ipso
e0ipso / compound-filter-ext.json-api.md
Last active Aug 29, 2015
JSON API compound filters extension
View compound-filter-ext.json-api.md

Relational filters JSON API extension

This extension provides documentation on how to filter based on relationships.

Given a requested resource (resource from now on) that contains several relationships (rel1, rel2, … from now on), you can apply filters on the resource based on conditions on rel1, rel2, … The default behavior is to filter the elements on resource, unless otherwise is specified.

The following request returns only the resource entities that contain a relationship that meets the filter:

GET /resource?filter[rel1.conditionField][value]=value1