Skip to content

Instantly share code, notes, and snippets.

View edutrul's full-sized avatar
💭
Changing the world

Eduardo Telaya edutrul

💭
Changing the world
View GitHub Profile
@edutrul
edutrul / ScrollDown_with_classic_loop.js
Created April 22, 2017 15:56
[REACT NATIVE] Scroll down with classic loop
import React, { Component } from 'react';
import { AppRegistry, ScrollView, Image, Text } from 'react-native'
class IScrolledDownAndWhatHappenedNextShockedMe extends Component {
render() {
var rows = [];
for (var i = 0; i < 30; i++) {
rows.push(<Text style={{fontSize:1+i}}>Te amo Alexandra</Text>);
}
return (
@edutrul
edutrul / ScrollDown_with_awesome_loop.js
Created April 22, 2017 17:15
ScrollDown_with_awesome_loop.js
import React, { Component } from 'react';
import { AppRegistry, ScrollView, Image, Text } from 'react-native'
class IScrolledDownAndWhatHappenedNextShockedMe extends Component {
render() {
return (
<ScrollView>
{Array.apply(0 , Array(50)).map(function (x, i) {
return <Text style={{fontSize:1+i, color: 'red'}}>Te amo Alexandra ♡ {i} - {x}</Text>;
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
@edutrul
edutrul / views-view-unformatted--hero_slider--block_homepage_slider.htm.twig
Created May 26, 2017 19:08
templates/views/views-view-unformatted--hero_slider--block_homepage_slider.html.twig
{#
/**
* @file
* Theme override for main view template.
*
* Available variables:
* - attributes: Remaining HTML attributes for the element.
* - css_name: A css-safe version of the view name.
* - css_class: The user-specified classes names, if any.
* - header: The optional header.
@edutrul
edutrul / KINT-tip.md
Created May 26, 2017 23:03
KINT tip from Jorge Salinas

Si usan {{ dump(variable) }} o {{ kint(variable) }} en twig y les da un wod o un error 500 al cargar la página, 99% del tiempo es por falta de memoria. En kint lo solucionan poniendo esto en el settings.local.php

require_once DRUPAL_ROOT . ‘/modules/contrib/devel/kint/kint/Kint.class.php’; Kint::$maxLevels = 6;

con dump() no hay solucion :( Por si sirve 🤓

@edutrul
edutrul / mymodule.install
Created June 7, 2017 16:02
Removes FIELD_NAME from ALL content types on DRUPAL8
/**
* Removes FIELD_NAME from ALL content types.
*/
function MYMODULE_update_8001(&$sandbox) {
$contentTypes = [
'blog_post',
'case_study',
'industry',
'video',
'whitepaper'
@edutrul
edutrul / ShipPackageFlowForm.php
Created June 26, 2017 02:45
Create new form element(Dropdown) in drupal 8 ajax and set image from taxonomy term
<?php
namespace Drupal\ship_package\Form;
use Drupal\Core\Url;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\HtmlCommand;
use Drupal\taxonomy\Entity\Term;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
@edutrul
edutrul / README--for-adding-custom-class-to-ckeditor.md
Last active July 3, 2017 15:52
How to add a custom class to ckeditor in drupal8
  1. Open format editor of your preference admin/config/content/formats/manage/basic_html
  2. Add styles BUTTON (Drag and drop)
  3. A new tab will be created "Styles Dropdown"
  4. Click on "Styles Dropdown" tab
  5. Add ul.two-column--list|Two column list
  6. (HIGHLY IMPORTANT) if you have have "Limit allowed HTML tags and correct faulty HTML" then Make sure
      is added, IF NOT PLEASE add it.
    • Save it!
    • Add ul.two-column--list { columns: 2; } in your current theme. Ckeditor automatically will find it.
    • Now create a content and locate on a textarea formatter field
@edutrul
edutrul / mymodule.php
Last active July 30, 2017 05:45
Implement STATES on drupal8
<?php
$formIds = [
'node_location_form',
'node_location_edit_form',
];
if (in_array($form_id, $formIds)) {
$form['#attached']['library'][] = 'care_location/care_location_node_form';
$form['field_location_google_streetview']['#states'] = [
'visible' => [
':input[name="field_location_what_to_display"]' => ['value' => 'field_location_google_streetview'],
@edutrul
edutrul / convert-integer-to-roman.php
Created September 8, 2017 16:26
How to convert integer to Roman number
<?php
/**
* Converts integer to Roman.
*
* @param int $integer
* Integer to be converted to Roman string.
*
* @return string
*/
public function integerToRoman($integer) {