Skip to content

Instantly share code, notes, and snippets.

View keopx's full-sized avatar

Ruben Egiguren keopx

View GitHub Profile
<?php
$file = system_retrieve_file($remote_file_url);
$node->field_image[$node->language][] = (array) $file;
node_save($node);
@keopx
keopx / speed_test.php
Created July 7, 2015 07:52
Speed Test: array_push vs $array[]
<?php
$time_start = microtime(true);
$myArray = array();
for ($i = 0; $i < 100000; ++$i) {
$myArray[] = $i;
$myArray[] = 'test a string';
}
@keopx
keopx / .bashrc
Created June 27, 2015 15:47
Actualiza y limpia tu Linux con una sola orden
function update () {
sudo apt-get update -y && echo "" && \
sudo apt-get dist-upgrade -y && echo "" && \
sudo apt-get upgrade -y && echo "" && \
sudo apt-get autoremove -y && echo "" && \
sudo localepurge && echo "" && \
sudo deborphan | xargs sudo apt-get remove -y --purge && echo "" && \
sudo apt-get autoclean -y && echo "" && \
sudo apt-get moo
}
@keopx
keopx / drupal8_reinstall.sh
Last active April 25, 2017 17:18
Drupal 8 reinstall site script
#!/bin/bash
cd drupal
sudo rm -fr vendor
composer install
sudo chmod 777 sites/default
cd sites/default
rm -fr settings.php services.yml
# for developers only (sets up some dev mode settings, do this before install!)
cp ../example.settings.local.php ./settings.local.php
# for everyone
@keopx
keopx / Foreign_keys.sql
Created April 7, 2015 13:36
View FOREIGN KEY
SELECT *
FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS
WHERE CONSTRAINT_TYPE = 'FOREIGN KEY'
#!/bin/bash
docker stop `docker ps -aq`
docker rm `docker ps -aq`
docker rmi `docker images -aq`
@keopx
keopx / demo_deploy.install.php
Last active October 27, 2015 02:00
Drupal Deploy process using hook_update_N on custom module for deploy
function demo_deploy_update_7001() {
# Reverting a feature should not be done in the visual interface
# or using drush fr, but should rather be done in the hook_update_n().
# To determine the component name (example views_view), make sure you are
# using version 2.x of Features, and visit the page for your features.
# In parentheses you will see the machine name for each component.
features_revert(array(
'demo_feature' => array(
'views_view',
),
@keopx
keopx / doc2odt.sh
Created February 27, 2015 12:34
Convertir muchos documentos de DOC a ODT y otros formatos
#Convertir muchos documentos de DOC a ODT y otros formatos:
libreoffice --invisible --convert-to odt *.doc
<?php
/**
* Implement of drush_hook_COMMAND_validate().
*
* Prevent catastrophic sql-sync to live. Note that this file has to be local to the
* machine that intitiates sql-sync command.
*/
function drush_policy_sql_sync_validate($source = NULL, $destination = NULL) {
if (strstr($destination, '.prod')) {