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 / babies_main_dart_correct_google.dart
Created June 6, 2018 05:27
babies_main_dart_correct_google.dart (this is correct version rather than in https://codelabs.developers.google.com/codelabs/flutter-firebase/#8 )
import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
const MyApp();
@override
Widget build(BuildContext context) {
@edutrul
edutrul / dar_class_example.dart
Created June 2, 2018 15:01
Dart class example
class Point {
// num is the parent class of `double` and `int`.
num x;
num y;
num z;
/**
* This is like
* Point(num x, num y, num z) {
this.x = x;
this.y = y;
@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;
@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 / 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 / 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' => 'example@example.com'
]
];
$node = \Drupal::entityTypeManager()->getStorage('node')->create($data);
$violations = $node->validate();
@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 / 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 / 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;
}