Skip to content

Instantly share code, notes, and snippets.

View oskarcalvo's full-sized avatar

Oskar Calvo oskarcalvo

View GitHub Profile
<?php
$query = \Drupal::entityQuery('cub');
$result = $query->execute();
$entidades = function ($result){
$list = [];
foreach($result as $cub) {
$list[] = $cub;
$ curl -I http://d7.local/node/3
HTTP/1.1 200 OK
Date: Mon, 06 Feb 2017 12:09:49 GMT
Server: Apache/2.4.10 (Debian)
X-Content-Type-Options: nosniff
X-Drupal-Cache: HIT
Etag: "1486381624-0"
Content-Language: es
X-Frame-Options: SAMEORIGIN
Link: </node/3>; rel="shortlink",</node/3>; rel="canonical"
#!/bin/bash
# Help menu
print_help() {
cat <<-HELP
This script is used to fix permissions of a Drupal installation
you need to provide the following arguments:
1) Path to your Drupal installation.
2) Username of the user that you want to give files/directories ownership.
@oskarcalvo
oskarcalvo / clean_empty_values.php
Last active August 2, 2017 08:00
a function to clean arrays with empty values
<?php
/**
* Remove keys with empty values.
* @param array $array
*
* @return array
*/
function clean_empty_values(array $array) {
return array_filter($array, function ($item) {
return empty($item) ? FALSE : TRUE;
<?php
<?php
/**
* Created by PhpStorm.
* User: oskar
* Date: 3/10/17
* Time: 10:00
*/
$time_start = microtime(true);
<?php
<?php
namespace SwitchClass;
$time_start = microtime(true);
echo memory_get_usage(), "\n";
/**
* Created by PhpStorm.
* User: oskar
#https://askubuntu.com/questions/761713/how-can-i-downgrade-from-php-7-to-php-5-6-on-ubuntu-16-04
Switch PHP version:
From php5.6 to php7.0:
Apache:
sudo a2dismod php5.6 ; sudo a2enmod php7.0 ; sudo service apache2 restart
CLI:
sudo update-alternatives --set php /usr/bin/php7.0
From php7.0 to php5.6:
Apache:
<?php
$query = \Drupal::entityQuery('cub');
$result = $query->execute();
$entidades = array_values($result);
// object $entidad con todas los registros guardasdos de cub
$entidad = entity_load_multiple('cub', $entidades);
?>
@oskarcalvo
oskarcalvo / menu_icon.php
Last active March 20, 2018 14:01
menu_icon.php
<?php
/**
* {@inheritdoc}
*
* @see hook_preprocess_menu()
*/
function module/theme_preprocess_menu(&$variables) {
if($variables['menu_name'] == '$menu_name' ) {
<?php
/**
* This file is included very early. See autoload.files in composer.json and
* https://getcomposer.org/doc/04-schema.md#files
*/
use Dotenv\Dotenv;
use Dotenv\Exception\InvalidPathException;