Skip to content

Instantly share code, notes, and snippets.

View delineas's full-sized avatar
🚀
Launching...

Daniel Primo delineas

🚀
Launching...
View GitHub Profile
@delineas
delineas / install_drush.sh
Created October 2, 2017 08:05
Instalar Drush Launcher
# Opcional: Posiciónate en el terminal en tu carpeta de drupal
cd /micarpeta/midrupal
# Descarga el launcher en Os x
curl -OL https://github.com/drush-ops/drush-launcher/releases/download/0.4.2/drush.phar
# Para Linux
wget -O drush.phar https://github.com/drush-ops/drush-launcher/releases/download/0.4.2/drush.phar
# Convierte el fichero en ejecutable
chmod +x drush.phar
@delineas
delineas / gist:0e3e3f055efdbe696d3a9e7787c64888
Created October 1, 2017 22:54 — forked from remcotolsma/gist:5884430
Gravity Forms calculate number days between 2 date fields
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
var ms_one_day = 1000 * 60 * 60 * 24;
var form_id = '1';
var date_format = 'dd-mm-yy';
var field_date_start = $( '#input_' + form_id + '_1' );
var field_date_end = $( '#input_' + form_id + '_2' );
@delineas
delineas / text.php
Last active September 25, 2017 22:37
Drupal 8 generate Link Internal
<?php
use Drupal\Core\Link;
Link::fromTextAndUrl($domain->label(), Url::fromUri('internal:/admin/content/domain-content/' . $domain->id()));
@delineas
delineas / index.php
Created September 25, 2017 20:53
PHP report errors
<?php
if($_SERVER['REMOTE_ADDR'] == 'xx.xx.xx.xx') {
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
}
else {
error_reporting(0);
ini_set('display_errors', FALSE);
}
@delineas
delineas / D8.md
Created September 10, 2017 18:58 — forked from leymannx/D8.md

#Drupal 8 snippets

##Create absolute URL:

$options = ['absolute' => TRUE];
$url_object = Drupal\Core\Url::fromRoute('entity.node.canonical', ['node' => $nid], $options);
// will output http://example.com/path-to-my-node

##Create absolute link object (and inner span):

@delineas
delineas / drupal_composer_install.sh
Last active August 2, 2017 15:02
Composer Create Drupal Env
composer create-project drupal/drupal drupal_folder_example
cd drupal_folder_example
drush si --db-url=mysql://root:root@localhost/drupal_folder_example
drush upwd admin --password="easypassword"
composer require drupal/console:~1.0 --prefer-dist --optimize-autoloader
@delineas
delineas / bash.sh
Last active August 2, 2017 07:50
Node Mac Reinstall
# force delete
brew uninstall --force node
# change node_modules permission
sudo chown -R ${USER} /usr/local/lib/node_modules
# delete old node_modules (it's creepy, I know, but it's necessary)
rm -rf /usr/local/lib/node_modules
# free a lot of memory
brew cleanup
# install node and gpm
brew install node
@delineas
delineas / mymodule.drush.inc
Created July 19, 2017 16:11
Drush entity list Drupal 8
<?php
/**
* Implements hook_drush_command().
*/
function MYMODULE_drush_command() {
$commands['mymodule-entity-list'] = [
@delineas
delineas / .env
Last active December 14, 2017 19:14
Docker config mariadb container
LOCAL_LISTEN_ADDR=192.168.99.100:
HOST_PATH_HTTPD_DATADIR=~/Sites/www
HOST_PATH_MYSQL_DATADIR=~/Sites/mariadb
HOST_PATH_PGSQL_DATADIR=~/Sites/pgsql
HOST_PATH_MONGO_DATADIR=~/Sites/mongo
@delineas
delineas / __INDEX.txt
Created June 6, 2017 17:21 — forked from facine/__INDEX.txt
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes: