Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View e0ipso's full-sized avatar
🏠
Working from home

Mateu Aguiló Bosch e0ipso

🏠
Working from home
View GitHub Profile
# 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 October 13, 2014 15:33
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 August 29, 2015 14:07
Drupal local update. Update your local database based on a remote environment.
<?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.',
#!/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 August 29, 2015 14:08
Accessors and mutators
<?php
class MyController extends ControllerBase implements ControllerInterface {
/**
* @var MyClass1
* Object of Class 1
*/
protected $obj1;
@e0ipso
e0ipso / rest-performance
Last active August 29, 2015 14:10
REST modules performance comparison.
# 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 August 29, 2015 14:13
RESTful 7.x-2.x - Mocks
// Declares the CRUD operations (including the request parsing for filters, fields, sorts, …)
// Composed by a swappable DataResource.
@e0ipso
e0ipso / array_key_exists.php
Last active August 29, 2015 14:15
empty vs array_key_exists
<?php
define('ITERATIONS', 10000000);
$array = array(
'foo' => 'bar',
'baz' => 'zzz',
);
for ($i = 0; $i < ITERATIONS; $i++) {
@e0ipso
e0ipso / comparison.php
Created February 16, 2015 12:45
isset & array_key_exists
<?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 / compound-filter-ext.json-api.md
Last active August 29, 2015 15:39
JSON API compound filters extension

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