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
@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 / 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 / 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 / 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;
#!/bin/bash
cat <<EOF > /tmp/personal.json
{
"git": {
"user": {
"name": "Enter your name",
"email": "your@email.sex"
},
"core": {
"editor": "vi"
@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.',
@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) {
}
}
}
+
+/**
# 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'
-- Select all media galleries and find all images in there that follow the path structure: public://images/%/%/%/%
SELECT n.nid, fmi.field_media_items_fid, file.uri
FROM
node n
INNER JOIN
field_data_field_media_items fmi ON fmi.entity_id = n.nid
INNER JOIN
file_managed file ON file.fid = fmi.field_media_items_fid
WHERE
n.type = 'media_gallery'
@e0ipso
e0ipso / operations.drush.inc
Created November 29, 2013 09:01
Drush command to update your local environment syncing down the DB from a remote environment, running updates and reverting all features.
<?php
/**
* Implementation of hook_drush_command().
*/
function operations_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.',