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 / php-geocode.php
Last active October 6, 2017 04:40
php-geocode from php library kamranahmedse - here code snippet
<?php
// Introduce the class into your scope.
use KamranAhmed\Geocode\Geocode;
// Optionally you can pass the API key for Geocoding.
$geocode = new Geocode();
// Get the details for the passed address.
@edutrul
edutrul / module_name.install
Created November 24, 2017 19:30 — forked from jmolivas/module_name.install
Update field data table and configuration storage object.
<?php
/**
* Update field data table and configuration storage
*/
function _update_field_data(
$entityType,
$field,
$valueMapping,
@edutrul
edutrul / mymodule.css
Created December 24, 2017 18:05 — forked from AlexSkrypnyk/mymodule.css
Drupal 'add more' and 'remove single' AJAX buttons on multi value custom field using FormAPI
input.form-submit.button-small {
padding: 4px 8px;
font-weight: bold;
}
.container-inline input.form-submit.button-small + .ajax-progress.ajax-progress-throbber .throbber {
position: absolute;
left: 19px;
margin-top: 7px;
}
@edutrul
edutrul / mymodule.css
Created December 24, 2017 18:05 — forked from AlexSkrypnyk/mymodule.css
Drupal 'add more' and 'remove single' AJAX buttons on multi value custom field using FormAPI
input.form-submit.button-small {
padding: 4px 8px;
font-weight: bold;
}
.container-inline input.form-submit.button-small + .ajax-progress.ajax-progress-throbber .throbber {
position: absolute;
left: 19px;
margin-top: 7px;
}
@edutrul
edutrul / pull.sh
Created February 13, 2018 16:11
AUTOMATIC PULL
#!/bin/bash
while true
do
cd ~/projects/XXX/ && git pull origin master
sleep 60
done
@edutrul
edutrul / sandwich_sandwich.info.yml
Created March 14, 2018 15:34
This is an example on how to create a custom plugin type and create plugin instances. This contains - Plugin type (Cheese) - The plugin type is Manager(who controlls all below:) - It has Annovation discovery - It has an interface to declare methods - It has an asbtract base class which will be as a kick starter for all plugin instances. - 2 plug…
name: 'sandwich'
type: module
description: 'Example plugin type'
core: 8.x
package: 'Custom'
@edutrul
edutrul / inAnyPartOrHookToUpdateOrSave.php
Created March 17, 2018 20:28
How to validate programmatically using a known constraint UniqueField
<?php
$data = [
'type' => 'article',
'title' => 'THis is an article test programmatically created',
'field_email' => [
'value' => '[email protected]'
]
];
$node = \Drupal::entityTypeManager()->getStorage('node')->create($data);
$violations = $node->validate();
@edutrul
edutrul / index.php
Created April 18, 2018 23:25
webscrapping example
<?php
// mkdir webscrapping folder
// cd webscrapping
// Then run composer require fabpot/goutte
// then create index.php with below content
require __DIR__ . '/vendor/autoload.php';
@edutrul
edutrul / layoutuid_main.dart
Created May 20, 2018 05:22
layoutuid_main.dart
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Widget titleSection = new Container(
@edutrul
edutrul / dart_first_steps.dart
Created June 2, 2018 14:01
Dart language first steps
var _nobleGases = [0, 1];
/* Short way for functions in a single line of code, for instance:
* bool isNoble(int atomicNumber) {
* return _nobleGases[atomicNumber] != null;
* }
* // Becomes:
* bool isNoble(int atomicNumber) => _nobleGases[atomicNumber] != null;
*/
bool isNoble(int atomicNumber) => _nobleGases[atomicNumber] != null;