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 / gist:6256131
Last active January 14, 2016 08:36
Use FBAutopost wrapper class to publish to a fan page.
<?php
try {
$fb = facebook_autopost();
$fb
->setDestination($facebook_page_id)
->publish(array(
'type' => 'status',
'params' => array('message' => t('Hello world.')),
));
}
@e0ipso
e0ipso / gist:6256142
Last active December 21, 2015 05:19
Use FBAutopost wrapper class to publish to the user's timeline (requires Facebook App approval).
<?php
try {
$fb = facebook_autopost();
$fb
->setDestination('me')
->publish(array(
'type' => 'status',
'params' => array('message' => t('Hello world.')),
));
}
@e0ipso
e0ipso / magic.php
Created September 13, 2013 09:33
Brief introduction to some OOP features present in PHP5.
<?php
/**
* A base class with getters and setters incorporated.
*/
class ObjectBase {
/**
* Setter function for a generic attribute.
*
* @param string $property_name
@e0ipso
e0ipso / drupal-reinstall.sh
Last active December 24, 2015 13:29
Shell alias to reinstall the current D8 site. Carefull! This will delete all your content and configuration and it's for core development purposes only. This alias is meant to be called from the Drupal root. This is a variation on http://alias.sh/drupal-install
# Add this to your .bash_profile / .bashrc / …
# Call this to reinstall a D8 development site.
function drupal-reinstall() {
pass=$(grep "'password' =>" sites/default/settings.php | grep -v '[\*#]'|sort|uniq|cut -f4 -d\');
username=$(grep "'username' =>" sites/default/settings.php | grep -v '[\*#]'|sort|uniq|cut -f4 -d\');
dbname=$(grep "'database' =>" sites/default/settings.php | grep -v '[\*#]'|sort|uniq|cut -f4 -d\');
sudo rm -rf sites/default;
sudo git checkout -- sites/default;
sudo chmod -R 777 sites/default;
@e0ipso
e0ipso / videos-aed-vimeo.md
Last active December 24, 2015 13:48
Lista de videos de Vimeo a incluir en el listado de la AED. Para una petición nueva se puede poner un comentario en este gist y actualizaré el contenido y la lista de la AED lo antes posible.
@e0ipso
e0ipso / field-contents.php
Last active December 27, 2015 16:58
Fetch field contents without loading whole entity.
<?php
/**
* Get the content of a field for a given array of entity ids. If the field
* contains multiple values for a given entity id, then only the latest is
* preserved.
*
* @param string $field_name
* The name of the field you need to retrieve.
* @param array $entity_ids
* An array containing the entity ids to look for.
@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.',
-- 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'
# 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) {
}
}
}
+
+/**