This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
var a = 5; | |
var b = 11; | |
var result = a + b; | |
print(a); | |
print(b); | |
print("Este es el resultado: $result"); | |
if (result % 2 == 0) { | |
print("$result es par"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fieldPlus = 'field_layout_region2_icon'; | |
$form[$fieldPlus]['widget']['#title'] = 'widget title'; | |
$form[$fieldPlus]['widget'][0]['#title'] = 'widget 0 title'; | |
$form[$fieldPlus]['widget'][0]['value']['#title'] = 'widget 0 value title'; | |
// If something is printed first! then that should be the way to go. | |
dpm($form[$fieldPlus]['widget']); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$entity_type = 'node'; | |
$bundle = 'layout'; | |
$field_name = 'field_layout_region1_items'; | |
$setting_name = 'promo'; | |
// Get selected view modes for bundle | |
$view_modes = \Drupal::service('entity_display.repository') | |
->getViewModeOptionsByBundle( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Title: Convert to correct timezone. | |
// Set default time. | |
$date = new DateTime('2018-05-17 22:29:00', new DateTimeZone('UTC')); | |
print $date->format('Y-m-d H:i:s') . "\n"; // 2018-05-17 22:29:00 | |
// Now convert to correct timestamp. | |
$date->setTimezone(new DateTimeZone('Australia/Brisbane')); | |
print $date->format('Y-m-d H:i:s') . "\n"; // 2018-05-18 08:29:00 | |
// ---------------------------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// mkdir webscrapping folder | |
// cd webscrapping | |
// Then run composer require fabpot/goutte | |
// then create index.php with below content | |
require __DIR__ . '/vendor/autoload.php'; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); |