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 / class08.php
Created April 25, 2025 21:54
Clase Robot php
<?php
class Robot {
private $size;
private $color;
private $price;
function __construct($size, $color, $price) {
@edutrul
edutrul / arrays-session-4.php
Last active April 10, 2025 22:07
Session 04 - Loops and Arrays
<?php
$movies = [
'Harry Potter I',
'Star Wars V',
'One Piece movie',
'Titanic',
'Frozen III',
'Exorcista 2025',
];
@edutrul
edutrul / sesion03.php
Created April 9, 2025 22:16
Session 3
<?php
$a = 5;
$b = 7;
$result = $a + $b;
checkIfTomorrowWillBeAfatalDay(FALSE);
print 'The total of this sum is: ' . $result;
@edutrul
edutrul / CMUArticleMigrationService.php
Last active June 21, 2024 16:23
Easy Cascade CMS migration so next CMU developers can extend it.
<?php
// File: src/Service/CMUArticleMigrationService.php
namespace Drupal\cmu_cascade\Service;
use Drupal\node\Entity\Node;
use Psr\Log\LoggerInterface;
/**
@edutrul
edutrul / CascadeMigrationCommands.php
Created June 20, 2024 21:27
src/Service/CascadeMigrationService.php
<?php
// File: src/Commands/CascadeMigrationCommands.php
namespace Drupal\custom_migration\Commands;
use Drush\Commands\DrushCommands;
use Drupal\custom_migration\Service\CascadeMigrationService;
/**
* A Drush command file for managing Cascade CMS migrations.
@edutrul
edutrul / llm.html
Created June 8, 2024 03:47
AI WITHOUT EXTERNAL APIS IN THE BROWSER https://eduardotelaya.com
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MLC AI Web LLM</title>
<script type="module">
import { MLCEngine } from "https://esm.run/@mlc-ai/web-llm";
async function initialize() {
@edutrul
edutrul / flag_game.html
Created February 5, 2023 02:45
Guess country name from 4 choices -- game generated by chat gpt3
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Country Image Guess Game</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="game">
<img id="flag" src="" alt="Flag">
@edutrul
edutrul / index.html
Created January 25, 2023 01:50
CHAT GPT 3 Product page listing automatically
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous">
<title>Product Page</title>
</head>
<body>
<div class="container mt-5">
<div class="row">
<div class="col-md-6">
@edutrul
edutrul / github-oauth2-client.php
Last active September 7, 2022 02:47 — forked from asika32764/github-oauth2-client.php
Simple PHP example of using Github's OAuth 2 API
<?php
// Code taken from https://gist.github.com/asika32764/b204ff4799d577fd4eef
// Code changes by @edutrul "added https" in all responses
// Makes sure when creating the app you deploy to a hosting/cloud
// If you want to do it quickly then use heroku.
// When adding the app in github make sure you just add the domain name like https://example.com
// Notice the "https" being added in the callback, website and other fields in github page.
define('OAUTH2_CLIENT_ID', '<YOUR CLIENT ID>');
@edutrul
edutrul / mymodule--feature.js.js
Last active August 12, 2022 19:11
How to add javascript by using drupal 8 libraries using Drupalsettings(to pass php(backend) variables to js(frontend). This can be applied to files: ".theme", ".module"m "field formatter class", "views field handler", etc files. Also uses javascript drupal behaviours (great practice in D8) Plus contains "once" which only enables to execute one t…
// File js/mymodule--feature.js
(function ($) {
Drupal.behaviors.mymodule__feature = {
attach: function (context, drupalSettings) {
// Use once to avoid tu call multiple times a js.
$(document).once('feature').on('click', '.button--feature', (function (event) {
event.preventDefault();
if (typeof drupalSettings.mymodule.feature.id != 'undefined') {
console.log('Your great logic goes here and will NOT be called multiple times');
}