Skip to content

Instantly share code, notes, and snippets.

@urielhdz
urielhdz / index.php
Last active May 22, 2024 17:58
Sesión 3
<?php
trait ValidationInfo{
function validateRFC($rfc){
return strlen($rfc) == 13;
}
}
$anon_class = new class() {
use ValidationInfo;
};
@urielhdz
urielhdz / index.php
Created May 22, 2024 17:44
Sesión 2 PHP Labs
<?php
abstract class Employee {
public $employee_id;
public $name;
public $phone;
public $rfc;
abstract public function saludar();
@urielhdz
urielhdz / app.js
Created September 17, 2022 17:40
Consumir la API de dev.to
// https://dev.to/api/articles?username=iamluisj
// AJAX => Asynchronous JavaScript and XML
// XMLHttpRequest
// fetch
async function cargarPublicaciones() {
let respuesta = await fetch('https://dev.to/api/articles?username=uriel_hedz');
let jsonArticulos = await respuesta.json();
return jsonArticulos;
@urielhdz
urielhdz / app.js
Created June 20, 2022 16:39
React Hello world con importmaps
import React from "react";
import ReactDOM from "react-dom";
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render("Hello world");
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mi primera página con React</title>
</head>
<body>
@urielhdz
urielhdz / serviceworker.js.erb
Created September 20, 2019 04:39
Cache while revalidate service worker
var CACHE_VERSION = 'v2';
var CACHE_NAME = CACHE_VERSION + ':sw-cache-';
var files_list = [
// make sure serviceworker.js is not required by application.js
// if you want to reference application.js from here
'<%= asset_path "application.js" %>',
'<%= asset_path "application.css" %>',
require 'digest/sha1'
require "google/cloud/firestore"
firebase_credentials = File.open('./firebase-key.json').read
firestore = Google::Cloud::Firestore.new(project_id: 'livemusiccodigofacilito', credentials: './firebase-key.json')
track_ref = firestore.doc "tracks/main"
music_data = ""
loop do
sleep(2)
file_content = File.read("./music.txt")
if file_content != music_data
@urielhdz
urielhdz / index.html
Created August 9, 2019 15:20
Instalar tu página web, base del tutorial
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="manifest" href="/manifest.json">
<title>Document</title>
<style>
body,html{margin:0;}
@urielhdz
urielhdz / advanced.js
Created May 30, 2019 19:18
Calculator in NodeJS terminal
const readline = require('readline');
const interface = readline.createInterface({ input: process.stdin, output: process.stdout });
const question = require('./question')(interface);
const operaciones = {
"1": {
text: "Suma de dos números",
method: (n1, n2) => n1 + n2
},
"2": {
// Instalar express
// npm install express
// https://expressjs.com/en/starter/hello-world.html
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) =>{