diff --git a/.github/workflows/epic.yml b/.github/workflows/epic.yml new file mode 100644 index 00000000..87423bce --- /dev/null +++ b/.github/workflows/epic.yml @@ -0,0 +1,14 @@ +name: Epic issues for GitHub +on: + issues: + types: [opened, created, closed, reopened, deleted] +jobs: + epics: + runs-on: ubuntu-latest + name: Update epic issues + steps: + - name: Run epics action + uses: cloudaper/epics-action@v1.0.1 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + epic-label-name: epic diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml new file mode 100644 index 00000000..fc2c2b7c --- /dev/null +++ b/.github/workflows/greetings.yml @@ -0,0 +1,13 @@ +name: Greetings + +on: [pull_request, issues] + +jobs: + greeting: + runs-on: ubuntu-latest + steps: + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + issue-message: 'Gracias por colaborar con tu primer Issue, si ya sabes la solución, te invitamos a compartir tu PR' + pr-message: 'Gracias por mejorar este repo, estaremos atentos a este y proximos PR' diff --git a/.gitignore b/.gitignore index d9d66507..5a3f6827 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ *.obj *.lst - +.vscode **/node_modules/ \ No newline at end of file diff --git a/CONTRIBUTORS.MD b/CONTRIBUTORS.MD index 0c027c97..d375cf17 100644 --- a/CONTRIBUTORS.MD +++ b/CONTRIBUTORS.MD @@ -1,4 +1,14 @@ # CONTRIBUTORS PYLP ## 2020 -- Esteban Martini (@SuichiM) \ No newline at end of file +- Esteban Martini (@SuichiM) +- German Pautsch (@gpautsch) +- Francisco Martin Nacimiento (@martinnacimiento) +- Santiago Villar (@InahoAZ) +- Zarske Arnold Oscar (@AuxZarske) +- Rodrigo Leonel Uriarte (@rodrigoUriarte) +- Javier Kachuka (@javikachuka) +- Nicolas Sawczuk (@NicoSawczuk) +- John Babi (@charlesbabi) +- Facundo Silveira Do Santo (@facundSilveira) +- Andrea Zakowicz (@Tremoteam) \ No newline at end of file diff --git a/Dockerfile.firebase b/Dockerfile.firebase new file mode 100644 index 00000000..208f1161 --- /dev/null +++ b/Dockerfile.firebase @@ -0,0 +1,12 @@ +FROM php:7.2-apache + +# COPY unidad_6 /var/www/html/ + +# Instalando node +RUN curl --silent --location https://deb.nodesource.com/setup_18.x | bash - \ + && apt-get install --yes nodejs \ + && apt-get install --yes build-essential + +RUN npm install -g firebase-tools + +USER root diff --git a/Dockerfile.haskell_prolog b/Dockerfile.haskell_prolog index 78181f84..b2d40f3d 100644 --- a/Dockerfile.haskell_prolog +++ b/Dockerfile.haskell_prolog @@ -19,7 +19,7 @@ RUN apt-get install -y \ # Instalando node -RUN curl --silent --location https://deb.nodesource.com/setup_12.x | bash - \ +RUN curl --silent --location https://deb.nodesource.com/setup_20.x | bash - \ && apt-get install --yes nodejs \ && apt-get install --yes build-essential @@ -30,4 +30,4 @@ RUN cd javascript/ && npm install # RUN groupadd -r curso && useradd --no-log-init -r -g curso curso # USER curso -CMD ["npx", "nodemon", "javascript/index.js"] \ No newline at end of file +CMD ["npx", "nodemon", "javascript/index.js"] diff --git a/README.md b/README.md index cf53ad70..134f34fe 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Repositorio oficial de la práctica de la cátedra Paradigmas y Lenguajes de Pro ## Equipo de cátedra -| Cargo |Nombre | +| Cargo | Nombre | | ----------------------------------- | ----------------------------------- | | Responsable de Teoria (Adjunto) | Mgter. Pautsch, Jesús Germán Andrés | | Responsable de Práctica (Ayte 2da.) | Lic. Martini, Roque Esteban | @@ -14,6 +14,18 @@ Repositorio oficial de la práctica de la cátedra Paradigmas y Lenguajes de Pro Martini Esteban [github](https://github.com/SuichiM) [twitter](https://twitter.com/SuichiM) +## Preparando el entorno + +[guia para preparar el entorno](./unidad_0/README.md) + +## Lineamientos para la entrega de los ejercicios + +[Lineamientos](./docs/lineamientos_entrega.md) + +## Lineamientos sobre la producción de los video tutoriales + +[Lineamientos](./docs/lineamientos_video.md) + ## Acerca del Repositorio Toda colaboración es bienvenida, y apreciada, no dudes en colaborar con tu PR. diff --git a/docker-compose.yml b/docker-compose.yml index 445b2810..951c3f5a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -21,4 +21,14 @@ services: - ./unidad_4:/home - /home/javascript/node_modules ports: - - 3000:3000 \ No newline at end of file + - 3000:3000 + firebase: + build: + context: . + dockerfile: Dockerfile.firebase + volumes: + - ./unidad_6:/var/www/html + ports: + - 5000:5000 + - 9005:9005 + - 3001:80 \ No newline at end of file diff --git a/unidad_1/RESUMEN.MD b/docs/RESUMEN_PASCALFC.MD similarity index 92% rename from unidad_1/RESUMEN.MD rename to docs/RESUMEN_PASCALFC.MD index 6ed6586a..0b93435a 100644 --- a/unidad_1/RESUMEN.MD +++ b/docs/RESUMEN_PASCALFC.MD @@ -1,12 +1,12 @@ # Referencias Rapidas Esta es una referencia ultra liviana de los componentes principales de PascalFC debe descartarse como referencia principal para cualquier busqueda profunda referirse a: - - [Manual del Lenguaje](./docs/) - - [Guía de Usuario](./docs/) + - [Manual del Lenguaje](./pascal-fc_manualdelenguaje.pdf) + - [Guía de Usuario](./pascal-fc_guiaUsuario.pdf) # Ciclo de vida de un proceso -![](./img/process_lifecycle.png) +![](../img/process_lifecycle.png) ## creación diff --git a/docs/lineamientos_entrega.md b/docs/lineamientos_entrega.md new file mode 100644 index 00000000..d94b64e6 --- /dev/null +++ b/docs/lineamientos_entrega.md @@ -0,0 +1,145 @@ +# Lineamientos y convenciones para la entrega de los ejercicios + +En esta sección podrán encontrar los lineamientos y convenciones que se debe respetar al realizar distintas actividades referidas a las entregas de los ejercicios. + +- Creación de Issues de tipo `epic` para aglutinar los ejercicios de las distintas unidades. + +- Creación de Issues para cada ejercicio. + +- Creación de la branch para resolver el ejercicio + +- convencion de nombre de los archivos + +- Convencion de nombre del Pull Request + +Para la resolución de los ejercicios vamos a seguir un patron de 1-1-1-1 + +``` +1 ejercicio -> 1 issue -> 1 archivo -> 1 pull request +``` + +## Issues + +Los issues son los componentes que vamos a utilizar para representar tanto los trabajos practicos como los ejercicios de los mismos. + +Los issues para los trabajos practicos, van a contener un label especial que será asignado por la cátedra, que se denomina `epic`. + +> ⚠️ El momento de creación de los issues será consensuada con la cátedra para mantener limpio el repositorio en todo momento + + +## Creacion de issues + +> 💡 Para crear un issue debe ir al [repositorio oficial de la catedra](https://github.com/PYLP-UNaM/PYLP). En la pestaña de [Issues](https://github.com/PYLP-UNaM/PYLP/issues). Click en el boton `New issue`. + +## Creacion de issues para los ejercicios de un tema + +Cada tema plantea una serie de ejercicios los cuales se deberán resolver y entregar a traves del mecanismo de PR. + +Para ello será necesario que el alumno cree un issue por cada ejercicio planteado. Siguiendo las siguientes convenciones. + +**Titulo** + +``` +Ejercicio - <1erNombre>#(En caso que el apellido se repita) +``` + +**Descripcion** *\*opcional* +``` + +``` + +## Creacion de issues de tipo `epic` para cada TP + +Cada issue de tipo `epic` aglutinará los ejercicios referidos un tema en concreto. + +**Temas** + +`TP1 (PascalFC), MPI, OpenMP, Haskell, Prolog` + +**Titulo** + +El titulo del issue deberá respetar la siguiente convención + +```sh +TP - <1erNombre>#(En caso que el apellido se repita) +``` + +**Descripcion** + +La descripción del issue sera un checklist de los ejercicios del tema correspondiente, que a su vez serán issues en el repositorio siguiendo las convenciones de la seccion correspondiente. + +``` +- [ ] #[ISSUE_ID] Ejercicio[N] +- [ ] #[ISSUE_ID] Ejercicio[N] +... +- [ ] #[ISSUE_ID] Ejercicio[N] +``` + +> 💡 Recuerde que la etiqueta `epic` sera asignada por el personal de catedra + +## Creación de branch para la resolucion de ejercicios + +La branch creada para resolver un ejercicio siempre debe tener como origen la rama `master`. + +Se recomienda enfáticamente nombrar la rama siguiendo la siguiente convencion + +```sh +tp_ej +``` + +con ello el comando para la creacion de rama quedaría: + +``` bash +# asegurandonos siempre que partimos de master +git checkout -b tp_ej +``` + +## Nombres de archivo + +Al resolver un ejercicio, se debera crear un archivo con el mismo nombre del archivo base o en su defecto con el nombre `ejercicio`, seguido siempre de un guion bajo (`_`) y su apellido, en la ruta correspondiente + +ejemplo: + +`unidad_1/ejercicio_1/holamundo_.pfc` +`unidad_1/ejercicio_1/ejercicio1_.pfc` +. + +## Mensaje de commit + +En el mensaje de cada commit se debe expresar con claridad lo realizado, se puede seguir el siguiente ejemplo como formato: + +`se soluciona el ejercicio 1 del tp1`. + +## Pull request de los ejercicios + +Para hacer pull request al repositorio oficial, es decir realizar la entrega de los ejercicios, deben: + +- [x] Haber realizado el ejercicio o solucion. +- [x] Haber realizado el commit de la solucion con su mensaje correspondiente. +- [x] Haber hecho push a su repositorio forkeado de la catedra. `git push origin tp1_ej1`. + +Una vez completado la lista de acciones, deben: + +1. Ir al repositorio oficial, a la pestaña de `Pull requests` y click en el boton `New pull request`. + +2. Seleccionar como destino del Pull Request el repositorio `PYLP-UNaM/PYLP` y la rama `2020` y como origen su repositorio y la brach que posee la solucion del ejercicio. + +el pull request debera seguir la siguiente convencion: + +**Titulo** + +```sh +solucion Ejercicio - <1erNombre>#(En caso que el apellido se repita) +``` + +**Descripcion** *\*opcional* +``` + +``` + +## Revision de los ejercicios y cierre de los issues + +Es posible que surgan sugerencias o comentarios en los PR a fin de mejorar el proceso de entrega de los ejercicios, por los que deben estar atentos a las devoluciones. + +> ⚠️ En ningún caso el alumno debe marcar de manera manual alguna tarea como resuelta o cerrar los issues de manera manual. El cierre de los issues de los ejercicios se realizaran de manera automatica con las integraciones de los PR a la branch correspodiente. + diff --git a/docs/lineamientos_video.md b/docs/lineamientos_video.md new file mode 100644 index 00000000..18bac75c --- /dev/null +++ b/docs/lineamientos_video.md @@ -0,0 +1,10 @@ +# Lineamientos sobre la producción de los video tutoriales + +- duracion de entre **3 y 9 minutos** segun la extension del tema +- deben iniciar **presentandose**: apellido, nombre, catedra y cohorte +- se debe **expresar de manera clara y concisa el objetivo** *(tema)* del video +- se puede hacer una **breve** explicacion del algoritmo que se va a utilizar +- *opcionalmente se puede contextualizar el tema con la teoria de manera muy breve* +- desarrollar la explicación +- *opcionalmente se debe la ejecucion de la solucion* +- conclusiones sobre el tema y despedida \ No newline at end of file diff --git a/unidad_1/docs/pascal-fc_guiaUsuario.pdf b/docs/pascal-fc_guiaUsuario.pdf similarity index 100% rename from unidad_1/docs/pascal-fc_guiaUsuario.pdf rename to docs/pascal-fc_guiaUsuario.pdf diff --git a/unidad_1/docs/pascal-fc_manualdelenguaje.pdf b/docs/pascal-fc_manualdelenguaje.pdf similarity index 100% rename from unidad_1/docs/pascal-fc_manualdelenguaje.pdf rename to docs/pascal-fc_manualdelenguaje.pdf diff --git a/img/clone.png b/img/clone.png new file mode 100644 index 00000000..4fe42895 Binary files /dev/null and b/img/clone.png differ diff --git a/img/ej3_omp_1.png b/img/ej3_omp_1.png new file mode 100644 index 00000000..ab39f228 Binary files /dev/null and b/img/ej3_omp_1.png differ diff --git a/img/ej3_omp_2.png b/img/ej3_omp_2.png new file mode 100644 index 00000000..0422826e Binary files /dev/null and b/img/ej3_omp_2.png differ diff --git a/img/ej_5_mpi.png b/img/ej_5_mpi.png new file mode 100644 index 00000000..c045b30e Binary files /dev/null and b/img/ej_5_mpi.png differ diff --git a/unidad_0/img/fork.png b/img/fork.png similarity index 100% rename from unidad_0/img/fork.png rename to img/fork.png diff --git a/unidad_1/img/process_lifecycle.png b/img/process_lifecycle.png similarity index 100% rename from unidad_1/img/process_lifecycle.png rename to img/process_lifecycle.png diff --git a/unidad_0/README.md b/unidad_0/README.md index 59192008..6e3fb76c 100644 --- a/unidad_0/README.md +++ b/unidad_0/README.md @@ -16,13 +16,13 @@ _\* recomendacion de la catedra_ haga click en el boton fork _(ver imagen)_ y siga las instrucciones. esto creara una copia del repositorio en su cuenta. -![fork](./img/fork.png) +![fork](../img/fork.png) 3. Una vez terminado el fork, ud. tendrá una copia del repositorio en su cuenta, es éste repositorio con el cuál Ud. trabajará de manera local. 4. Para clonarse el repositorio en su maquina local. debe copiarse la url del repositorio. presionando el boton Code y el boton copiar. _(ver imagen)_ -![clone](./img/clone.png) +![clone](../img/clone.png) 5. una vez copiada la url, en una terminal debe ubicarse en la carpeta donde desea trabajar con el repositorio. y ejecutar el siguiente comando. @@ -38,6 +38,9 @@ cd /home/projects git clone https://github.com/SuichiM/PYLP ``` +### porque usamos fork? + +aca una explicación de como se contribuye en el mundo OS 👉 [video](https://www.youtube.com/watch?v=QntLv5BjUr0&feature=youtu.be) ## 1. Instalar docker ([¿Que es docker?](https://docs.docker.com/engine/)) @@ -47,6 +50,8 @@ se recomienda utilizar una distribución de linux e [instalar usando el reposito Si siguó las recomendaciones e instalo en linux y con el repositorio. revisar estos pasos de [post-instalacion.](https://docs.docker.com/engine/install/linux-postinstall/) +acá un **tutorial de como instalar docker** en linux: 👉 [tutorial](https://www.youtube.com/watch?v=JwqkjKkEIDw&feature=youtu.be) + ## 2. Instalar docker-compose ([¿Qué es y porqué usar docker-compose?](https://docs.docker.com/compose/)) [Instalar compose](https://docs.docker.com/compose/install/) @@ -55,9 +60,9 @@ Si siguó las recomendaciones e instalo en linux y con el repositorio. revisar e [Instalar VS Code](https://code.visualstudio.com/) -### 3.1 plugins recomendados +### 3.1 Instalar los siguientes plugins de VS Code -- Docker +- Docker (**Microsoft**) v1.5.0+ ## 4. Correr los container de la raiz diff --git a/unidad_0/img/clone.png b/unidad_0/img/clone.png deleted file mode 100644 index c1becf2d..00000000 Binary files a/unidad_0/img/clone.png and /dev/null differ diff --git a/unidad_1/README.md b/unidad_1/README.md index f825a47c..e2bdaeec 100644 --- a/unidad_1/README.md +++ b/unidad_1/README.md @@ -25,4 +25,4 @@ pfc2int ## Escribiendo codigo -[Referencias rapidas](./RESUMEN.MD) \ No newline at end of file +[Referencias rapidas](../docs/RESUMEN_PASCALFC.MD) \ No newline at end of file diff --git a/unidad_1/ejercicio_1/holaMundo.pfc b/unidad_1/ejercicio_1/holaMundo.pfc index a64f2108..ad02b340 100755 --- a/unidad_1/ejercicio_1/holaMundo.pfc +++ b/unidad_1/ejercicio_1/holaMundo.pfc @@ -1,17 +1,15 @@ -program ejercicio_1; +program ejericio_1; -process type printId (i : integer); +process type printId(rango:integer); begin - writeln('Soy el proceso ', i); + writeln('soy el proceso', rango); end; var - p1 , p2 ,p3 : printId; - -begin + p1, p2: printId; +begin cobegin - p1(1); - p2(2); - p3(3); - coend; -end. + p1(1); + p2(2); + coend; +end. \ No newline at end of file diff --git a/unidad_1/ejercicio_1/holaMundo_DaSilva.pfc b/unidad_1/ejercicio_1/holaMundo_DaSilva.pfc new file mode 100755 index 00000000..31eab3ee --- /dev/null +++ b/unidad_1/ejercicio_1/holaMundo_DaSilva.pfc @@ -0,0 +1,15 @@ +program ejericio_1; + +process type printId(rango:integer) +begin + writeln('soy el proceso', rango); +end; + +var + p1, p2: printId; +begin + cobegin + p1(1); + p2(2); + coend; +end. \ No newline at end of file diff --git a/unidad_1/ejercicio_2/README.md b/unidad_1/ejercicio_2/README.md index ac59e2b9..369b07ab 100644 --- a/unidad_1/ejercicio_2/README.md +++ b/unidad_1/ejercicio_2/README.md @@ -5,7 +5,7 @@ Realizar un programa que ejecute paralelamente 3 procesos: - 2 de los procesos debe imprimir _`X`_ números pares -- el otro _`Y`_ números pares. +- el otro _`Y`_ números impares. ## Objetivos diff --git a/unidad_1/ejercicio_2/ejercicio_2_DaSilva.pfc b/unidad_1/ejercicio_2/ejercicio_2_DaSilva.pfc new file mode 100644 index 00000000..f7f9c3aa --- /dev/null +++ b/unidad_1/ejercicio_2/ejercicio_2_DaSilva.pfc @@ -0,0 +1,45 @@ +program HolaMundo2; + +process type imprimirPares(cant:integer); +var + x:integer; + num:integer; +begin + num:=2; + for x:=1 to cant do + begin + writeln('P - generado: ',num); + num:=num+2; + end; +end; + +process type imprimirImpares(cant:integer); +var + x:integer; + num:integer; +begin + num:=1; + for x:=1 to cant do + begin + writeln('I - generado: ',num); + num:=num+2; + end; +end; + +var + p1,p2: imprimirPares; + cPares:integer; + cImpares:integer; + p3: imprimirImpares; +begin + writeln('ingrese la cantidad de nros Pares:'); + readln(cPares); + writeln('ingrese la cantidad de nros Impares:'); + readln(cImpares); + cobegin + p1(cPares); + p2(cPares); + p3(cImpares); + coend; + +end. diff --git a/unidad_1/ejercicio_3/ejercicio_3_DaSilva.pfc b/unidad_1/ejercicio_3/ejercicio_3_DaSilva.pfc new file mode 100644 index 00000000..48bbc5b2 --- /dev/null +++ b/unidad_1/ejercicio_3/ejercicio_3_DaSilva.pfc @@ -0,0 +1,44 @@ +program NumerosPrimos; + +process type numerosPrimos(inicio:integer; fin:integer; proceso:integer); +var + p,i,j,primo: integer; +begin + + + for i:=inicio to fin do + begin + primo:= 0; + for j:=1 to i do + begin + if (i mod j = 0) then + begin + primo:= primo + 1; + end; + end; + if (primo=2) then + begin + writeln('Proceso Número:', proceso, ' - ', 'Número Primo: ', i); + end; + end; + +end; + +var + p1,p2: numerosPrimos; + inicio_p1,inicio_p2,fin_1,fin_2:integer; +begin + writeln('ingrese un número de inicio para el Proceso 1:'); + readln(inicio_p1); + writeln('ingrese un número de fin para el Proceso 1:'); + readln(fin_1); + writeln('ingrese un número de inicio para el Proceso 2:'); + readln(inicio_p2); + writeln('ingrese un número de fin para el Proceso 2:'); + readln(fin_2); + + cobegin + p1(inicio_p1,fin_1,1); + p2(inicio_p2,fin_2,2); + coend; +end. \ No newline at end of file diff --git a/unidad_1/ejercicio_4/ejercicio_4 DaSilva.pfc b/unidad_1/ejercicio_4/ejercicio_4 DaSilva.pfc new file mode 100755 index 00000000..3692a096 --- /dev/null +++ b/unidad_1/ejercicio_4/ejercicio_4 DaSilva.pfc @@ -0,0 +1,67 @@ +program ProductoEscalar; +const LNG = 9; +const N = 5; +type + vector = array [0..LNG] of integer; + +var + i:integer; + resultado:integer; + v1, v2:vector; + +procedure cargar_vectores; +begin + for i := 0 to LNG do + begin + v1[i] := i ; + v2[i] := LNG - i ; + end; + + writeln('vector 1'); + for i := 0 to LNG do + begin + write(v1[i], ' - '); + end; + writeln; + writeln; + writeln('vector 2'); + for i := 0 to LNG do + begin + write(v2[i], ' - '); + end; + writeln; + writeln; +end; + +process type PRODUCTO(rango:integer; var s:semaphore); +var + ini,fin,j,local:integer; +begin + ini := rango*N; + fin := (rango*N + N)-1; + + for j := ini to fin do + begin + + local:=v1[j] * v2[j]; + wait(s); + resultado:=resultado+local; + writeln(rango, ': j=',j,' (', v1[j], '*', v2[j], ')=', local, ' + '); + signal(s); + end; +end; + +var + p1,p2:PRODUCTO; + sem: semaphore; +begin + + initial(sem,1); + resultado:=0; + cargar_vectores; + cobegin + p1(0, sem); + p2(1, sem); + coend; + writeln('El producto final es: ',resultado); +end. diff --git a/unidad_1/ejercicio_4/ejercicio_4.pfc b/unidad_1/ejercicio_4/ejercicio_4.pfc new file mode 100755 index 00000000..3692a096 --- /dev/null +++ b/unidad_1/ejercicio_4/ejercicio_4.pfc @@ -0,0 +1,67 @@ +program ProductoEscalar; +const LNG = 9; +const N = 5; +type + vector = array [0..LNG] of integer; + +var + i:integer; + resultado:integer; + v1, v2:vector; + +procedure cargar_vectores; +begin + for i := 0 to LNG do + begin + v1[i] := i ; + v2[i] := LNG - i ; + end; + + writeln('vector 1'); + for i := 0 to LNG do + begin + write(v1[i], ' - '); + end; + writeln; + writeln; + writeln('vector 2'); + for i := 0 to LNG do + begin + write(v2[i], ' - '); + end; + writeln; + writeln; +end; + +process type PRODUCTO(rango:integer; var s:semaphore); +var + ini,fin,j,local:integer; +begin + ini := rango*N; + fin := (rango*N + N)-1; + + for j := ini to fin do + begin + + local:=v1[j] * v2[j]; + wait(s); + resultado:=resultado+local; + writeln(rango, ': j=',j,' (', v1[j], '*', v2[j], ')=', local, ' + '); + signal(s); + end; +end; + +var + p1,p2:PRODUCTO; + sem: semaphore; +begin + + initial(sem,1); + resultado:=0; + cargar_vectores; + cobegin + p1(0, sem); + p2(1, sem); + coend; + writeln('El producto final es: ',resultado); +end. diff --git a/unidad_1/ejercicio_5/ejercicio_5_1_semaforos.pfc b/unidad_1/ejercicio_5/ejercicio_5_1_semaforos.pfc new file mode 100644 index 00000000..ea542b91 --- /dev/null +++ b/unidad_1/ejercicio_5/ejercicio_5_1_semaforos.pfc @@ -0,0 +1,19 @@ +program ejericio_1; + +process type printId(rango:integer; var s:semaphore); +begin + wait(s); + writeln('soy el proceso', rango); + signal(s); +end; + +var + p1, p2: printId; + sem: semaphore; +begin + initial(sem, 1); + cobegin + p1(1, sem); + p2(2, sem); + coend; +end. \ No newline at end of file diff --git a/unidad_1/ejercicio_5/ejercicio_5_1_semaforos_DaSilva.pfc b/unidad_1/ejercicio_5/ejercicio_5_1_semaforos_DaSilva.pfc new file mode 100644 index 00000000..ea542b91 --- /dev/null +++ b/unidad_1/ejercicio_5/ejercicio_5_1_semaforos_DaSilva.pfc @@ -0,0 +1,19 @@ +program ejericio_1; + +process type printId(rango:integer; var s:semaphore); +begin + wait(s); + writeln('soy el proceso', rango); + signal(s); +end; + +var + p1, p2: printId; + sem: semaphore; +begin + initial(sem, 1); + cobegin + p1(1, sem); + p2(2, sem); + coend; +end. \ No newline at end of file diff --git a/unidad_1/ejercicio_6/ejercicio_6_init_DaSilva.pfc b/unidad_1/ejercicio_6/ejercicio_6_init_DaSilva.pfc new file mode 100644 index 00000000..0a874a1c --- /dev/null +++ b/unidad_1/ejercicio_6/ejercicio_6_init_DaSilva.pfc @@ -0,0 +1,32 @@ +program gardens1; +var +count: integer; + +process turnstile1; +var + loop: integer; +begin + for loop := 1 to 5 do + begin + count := count + 1; + end; +end; (* turnstile1 *) + +process turnstile2; +var + loop: integer; +begin + for loop := 1 to 5 do + begin + count := count + 1; + end; +end; (* turnstile2 *) + +begin +count := 0; +cobegin + turnstile1; + turnstile2; +coend; +writeln('Total admitted: ',count) +end. \ No newline at end of file diff --git a/unidad_1/ejercicio_7/ejercicio_7.pfc b/unidad_1/ejercicio_7/ejercicio_7.pfc new file mode 100644 index 00000000..bfd7905c --- /dev/null +++ b/unidad_1/ejercicio_7/ejercicio_7.pfc @@ -0,0 +1,40 @@ +program ejercicio_4; +const + N = 10; NP = 2; LNG = 19; + +type myArray = array[0..LNG] of integer; + +var + array1 : myArray; + +process type cargar_vector(rango : integer; var sem: semaphore); +var + j, posInicial: integer; +begin + posInicial := rango*N; + wait(sem); + for j := posInicial to posInicial+N-1 do + begin + + writeln('soy ', rango, 'cargando ', j); + array1[j] := rango; + end; + signal(sem); + + +end; + +var + i:integer; + p0, p1 : cargar_vector; + s: semaphore; +begin + initial(s, 1); + cobegin + p0(0, s); + p1(1, s); + coend; + + for i := 0 to LNG do + write(array1[i], ' - '); +end. diff --git a/unidad_1/ejercicio_7/ejercicio_7_DaSilva.pfc b/unidad_1/ejercicio_7/ejercicio_7_DaSilva.pfc new file mode 100644 index 00000000..bfd7905c --- /dev/null +++ b/unidad_1/ejercicio_7/ejercicio_7_DaSilva.pfc @@ -0,0 +1,40 @@ +program ejercicio_4; +const + N = 10; NP = 2; LNG = 19; + +type myArray = array[0..LNG] of integer; + +var + array1 : myArray; + +process type cargar_vector(rango : integer; var sem: semaphore); +var + j, posInicial: integer; +begin + posInicial := rango*N; + wait(sem); + for j := posInicial to posInicial+N-1 do + begin + + writeln('soy ', rango, 'cargando ', j); + array1[j] := rango; + end; + signal(sem); + + +end; + +var + i:integer; + p0, p1 : cargar_vector; + s: semaphore; +begin + initial(s, 1); + cobegin + p0(0, s); + p1(1, s); + coend; + + for i := 0 to LNG do + write(array1[i], ' - '); +end. diff --git a/unidad_3/mpi/README.md b/unidad_3/mpi/README.md index d3baace1..80e683d3 100755 --- a/unidad_3/mpi/README.md +++ b/unidad_3/mpi/README.md @@ -10,35 +10,35 @@ Su principal característica es que no precisa de memoria compartida, por lo que ## Funciones -| | | | | -| ------------- | -------------------- | --------------- | --------------- | -| MPI_Init | MPI_Iprobe | MPI_Bcast | MPI_Cart_coords | -| MPI_Finalize | MPI_Probe | MPI_Scatter | MPI_Cart_rank | -| MPI_Comm_rank | MPI_Get_count | MPI_Gather | MPI_Cart_shift | -| MPI_Comm_size | MPI_Sendrecv | MPI_Reduce | MPI_Type_vector | -| MPI_Send | MPI_Sendrecv_replace | MPI_Allreduce | MPI_Type_commit | -| MPI_Recv | MPI_Barrier | MPI_Scan | MPI_Type_free | -| MPI_Isend | MPI_Waitall | MPI_Comm_split | MPI_Pack | -| MPI_Irecv | MPI_Request_free | MPI_Comm_free | MPI_Unpack | -| MPI_Test | MPI_Error_string | MPI_Cart_create | MPI_Wtime | -| MPI_Wait | | | - -## Tipos de datos - -| | | | | -| ---------- | -------- | ----------- | ------------ | -| MPI_Status | MPI_Comm | MPI_Request | MPI_Datatype | - -### Constantes - -| | | | | -| -------------- | ------------------ | ------------------- | -------------- | -| MPI_COMM_WORLD | MPI_DOUBLE | MPI_FLOAT_INT | MPI_PACKED | -| MPI_INT | MPI_UNSIGNED_CHAR | MPI_LONG_INT | MPI_UB | -| MPI_CHAR | MPI_UNSIGNED_SHORT | MPI_DOUBLE_INT | MPI_LB | -| MPI_BYTE | MPI_UNSIGNED | MPI_SHORT_INT | MPI_ANY_SOURCE | -| MPI_LONG | MPI_UNSIGNED_LONG | MPI_2INT | MPI_ANY_TAG | -| MPI_FLOAT | MPI_LONG_DOUBLE | MPI_LONG_DOUBLE_INT | MPI_ERROR | +| | | | | +| --------------------------------------------------------------------------------- | -------------------- | --------------- | --------------- | +| [**MPI_Init**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Init) | MPI_Iprobe | [**MPI_Bcast**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Bcast) | MPI_Cart_coords | +| [**MPI_Finalize**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Finalize) | MPI_Probe | [**MPI_Scatter**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Scatter) | MPI_Cart_rank | +| [**MPI_Comm_rank**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Comm_rank) | MPI_Get_count | [**MPI_Gather**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Gather) | MPI_Cart_shift | +| [**MPI_Comm_size**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Comm_size) | MPI_Sendrecv | [**MPI_Reduce**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Reduce) | MPI_Type_vector | +| [**MPI_Send**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Send) | MPI_Sendrecv_replace | MPI_Allreduce | MPI_Type_commit | +| [**MPI_Recv**](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=MPI_Recv) | MPI_Barrier | MPI_Scan | MPI_Type_free | +| **MPI_Isend** | MPI_Waitall | MPI_Comm_split | MPI_Pack | +| **MPI_Irecv** | MPI_Request_free | MPI_Comm_free | MPI_Unpack | +| MPI_Test | MPI_Error_string | MPI_Cart_create | MPI_Wtime | +| **MPI_Wait** | | | + +## [Tipos de datos](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=mpi_datatypes) + +| | | | | +| -------------- | ------------ | --------------- | ------------ | +| **MPI_Status** | **MPI_Comm** | **MPI_Request** | MPI_Datatype | + +### [Constantes](https://lsi.ugr.es/jmantas/ppr/ayuda/mpi_ayuda.php?ayuda=mpi_const_types) + +| | | | | +| ------------------ | ------------------ | ------------------- | ------------------ | +| **MPI_COMM_WORLD** | MPI_DOUBLE | MPI_FLOAT_INT | MPI_PACKED | +| **MPI_INT** | MPI_UNSIGNED_CHAR | MPI_LONG_INT | MPI_UB | +| MPI_CHAR | MPI_UNSIGNED_SHORT | MPI_DOUBLE_INT | MPI_LB | +| MPI_BYTE | MPI_UNSIGNED | MPI_SHORT_INT | **MPI_ANY_SOURCE** | +| MPI_LONG | MPI_UNSIGNED_LONG | MPI_2INT | **MPI_ANY_TAG** | +| MPI_FLOAT | MPI_LONG_DOUBLE | MPI_LONG_DOUBLE_INT | MPI_ERROR | ## Compilando mis fuentes diff --git a/unidad_3/mpi/ejercicio_2/README.md b/unidad_3/mpi/ejercicio_2/README.md new file mode 100755 index 00000000..53fe0da9 --- /dev/null +++ b/unidad_3/mpi/ejercicio_2/README.md @@ -0,0 +1,18 @@ +# ejercicio 2 + +## Enunciado + +hacer un programa que lance `X` procesos, segun si su numero de rango sea par o impar, deberan imprimir: + +```c++ +# procesos pares +cout<<"soy el proceso: "< el proceso 0 debe verificar cuantos elementos son multiplos del elemento en la posicion 0 + +> el proceso 1 debe verificar cuantos elementos son multiplos del elemento en la posicion 1 + +> el proceso 2 debe verificar cuantos elementos son multiplos del elemento en la posicion 2 + +> el proceso n debe verificar cuantos elementos son multiplos del elemento en la posicion n + +Luego imprimir el resultado por pantalla y opcionalmente obtener cual es el que mayor multiplos tuvo mediante la instruccion `MPI_Reduce` . + +## Objetivos + +- Aprender a usar `MPI_Bcast`. +- Aprender a usar `MPI_Reduce` para obtener el maximo. \ No newline at end of file diff --git a/unidad_3/openmp/README.md b/unidad_3/openmp/README.md index b559513f..f8b82e3a 100755 --- a/unidad_3/openmp/README.md +++ b/unidad_3/openmp/README.md @@ -1,28 +1,64 @@ -# OpenMP +# OpenMP -es un ... +`OpenMP` es una interfaz de programación de aplicaciones para la programación multiproceso de memoria compartida en múltiples plataformas. Permite añadir concurrencia a los programas escritos en C, C++ y Fortran sobre la base del modelo de ejecución fork-join. + +La API de `OpenMP` Sigue un modelo escalable con una interfaz simple y flexible para desarrollar aplicaciones paralelas en plataformas que van desde ordenadores personales hasta superordenadores. + +La API define únicamente el estándar que hay que seguir para poder utilizar la interfaz. ## Componentes del estandar -## Funciones +--- + +## Funciones/Directivas + +Las directivas se basan en #pragma directivas definidas en los estándares de C y C++. Los compiladores que admiten la API de OpenMP C y C++ incluirán una opción de línea de comandos que active y permita la interpretación de todas las directivas de compilador de OpenMP. + +Cada directiva comienza con #pragma omp , para reducir la posibilidad de conflicto con otras directivas pragma (que no son de OpenMP o de proveedor a OpenMP) con los mismos nombres. El resto de la Directiva sigue las convenciones de los estándares de C y C++ para las directivas de compilador. + +`#pragma omp [clausulas-comparticion]` +| | | | +| ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | +| [**pragma omp parallel**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp single**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp taskwait**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | +| [**pragma omp for**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp task**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp atomic**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | +| [**pragma omp parallel for**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp master**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp flush**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | +| [**pragma omp sections**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp critical**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp ordered**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | +| [**pragma omp parallel sections**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp barrier**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | [**pragma omp threadprivate**](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_directivas) | -## Tipos de datos +--- +## [Clausulas de Compartición de datos](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=omp_clausulas) -## Constantes +| | | +| --------------------- | ------------------------ | +| default(shared\|none) | lastprivate(list) | +| shared(list) | reduction(operator:list) | +| private(list) | nowait | +| firstprivate(list) | | +--- + +## [Planificadores de bucles](https://lsi.ugr.es/jmantas/ppr/ayuda/omp_ayuda.php?ayuda=schedule) + +1. Static +2. Dynamic +3. Guided +4. Auto +5. Runtime + +--- ## compilando los archivos para compilar el archivo fuente `.cpp` se debe ejecutar el comando `mpicxx`. - + debemos usar la opcion `-fopenmp` para indicarle que es un archivo que usa `OpenMP` con la opcion `-o` le damos el nombre que queremos al ejecutable. ```sh -mpicxx -fopenmp -o +g++ -fopenmp -o ``` ## Ejecutando los archivos @@ -31,4 +67,4 @@ Para ejecutar los programas corremos : ```sh ./ -``` \ No newline at end of file +``` diff --git a/unidad_3/openmp/ejercicio_1/README.md b/unidad_3/openmp/ejercicio_1/README.md new file mode 100644 index 00000000..9a1207db --- /dev/null +++ b/unidad_3/openmp/ejercicio_1/README.md @@ -0,0 +1,59 @@ +# Ejercicio 1 + +## Enunciado + +A partir del siguiente codigo: + +```c++ +#include +#include + +int main (){ + +int nthreads; +int thread; + +#pragma omp parallel private(nthreads, thread) + { + + thread = omp_get_thread_num(); + + nthreads = omp_get_num_threads(); + + std::cout<<"Hola Mundo soy la hebra ="<< thread <<" de "< g++ -fopenmp 01.cpp -o holaMundo + +#ejecutando +./holaMundo +``` + +2. hacer que el codigo de arriba se ejecute por 10 hilos. ¿cual es la rutina necesaria? + +3. ¿que pasa si se elimina la clausula `private`? + +4. crear una nueva variable fuera de la region paralela y asignale el valor `777` y definela dentro de la clausula `private` de la region paralela ¿Que pasa con su valor? + +5. Ahora en vez de definila dentro de una clausula de comparticion `firstprivate` + +## Objetivos + +- Iniciarnos en el aprendizaje de `OpenMP`. +- Aprender a usar `#pragma omp parallel`. +- Aprender a usar la clausula `firstprivate`. +- Aprender a usar la clausula `private`. +- Aprender a usar `omp_get_thread_num`. +- Aprender a usar `omp_get_num_threads`. +- Aprender a usar `omp_set_num_threads`. diff --git a/unidad_3/openmp/ejercicio_1/ejercicio_1.cpp b/unidad_3/openmp/ejercicio_1/ejercicio_1.cpp index c4dc0f4d..2f7e3b36 100755 --- a/unidad_3/openmp/ejercicio_1/ejercicio_1.cpp +++ b/unidad_3/openmp/ejercicio_1/ejercicio_1.cpp @@ -1,22 +1,20 @@ #include #include - + int main (){ - + int nthreads; int thread; -int NuevoValor = 222; - -omp_set_num_threads(10); -#pragma omp parallel private(nthreads, thread) firstprivate(NuevoValor) + +#pragma omp parallel private(nthreads, thread) { - + thread = omp_get_thread_num(); - + nthreads = omp_get_num_threads(); - - std::cout<<"Hola Mundo soy la hebra ="<< thread <<" de "< +#include + +#define N 10 +#define nthreads 4 + +int main (){ + int thread; + omp_set_num_threads(nthreads); + #pragma omp parallel private(thread) + { + thread = omp_get_thread_num(); + + for (int i = 0 ; i < N; i++){ + std::cout<<"Soy el proceso "< g++ -fopenmp ejercicio_2.cpp -o ej2.obj + +#ejecutando +./ej2.obj +``` + +2. Agregar la directiva `#pragma omp for` antes del bucle for. ¿Que ocurre? + +> `OpenMP` nos permite controlar la reparticion de iteraciones paralelas a traves de planificadores `schedule` cada uno de los cuales, actua de manera diferente. + +3. luego de la directiva `#pragma omp for` defina el `schedule` y pruebe los 4 planificadores disponibles + + 3.1. pruebe el planificador `static` + 3.2. pruebe el planificador `dynamic` + 3.3. pruebe el planificador `guided` + 3.4. pruebe el planificador `auto` + +## Objetivos + +- Aprender a paralelizar bucles con + + `#pragma omp for` + +- aprender el comportamiento de los distintos planificadores de bucles + + `#pragma omp for schedule([static|dynamic|guided|auto] )` \ No newline at end of file diff --git a/unidad_3/openmp/ejercicio_2/ejercicio_2.cpp b/unidad_3/openmp/ejercicio_2/ejercicio_2.cpp new file mode 100644 index 00000000..731398ab --- /dev/null +++ b/unidad_3/openmp/ejercicio_2/ejercicio_2.cpp @@ -0,0 +1,22 @@ +#include +#include + +#define N 10 +#define nthreads 4 + +int main (){ + + int thread; + + omp_set_num_threads(nthreads); + + #pragma omp parallel private(thread) + { + thread = omp_get_thread_num(); + + for (int i = 0 ; i < N; i++){ + std::cout<<"Soy el proceso "< "Una regla que aplicada a cada elemento de un dominio y da como resultado un valor en otro conjunto llamando imagen" + +``` +F(x) -> Y +``` + +Ejemplo: + +> Doble (5) -> 10 +> +> Capital(Argentina) -> Buenos aires + +## Declaración + +Una funcion se puede definir + +- **Por Comprension**: se define a partir de una formula o ecuacion. Ejemplo + +``` +Doble(x) = 2*x +``` + +- **Extension**: se define por un par ordenado donde se expresa para cada valor su resultado. Ejemplo + +``` +Capital = Argentina, Buenos aires + Uruguay, montevideo +``` + +## Características de la Programación Funcional + +- Se basa en un **Paradigma Declarativo**: donde el objetivo es expresar **QUE** hay que calcular y no tanto el **COMO** + +- **Transparencia Referencial**: El resultado de la función depende **unicamente** de los valores pasados como parametros en la llamada de la funcion. Es decir, todas las veces que llamemos a una función con los mismos parametros de entrada, la funcion va a devolver el mismo resultado. + +- No tiene **Efectos Laterales**: No se modifica nada de lo que se encuentre declarado fuera de la funcion, de hecho en la programación funcional pura, todas las declaraciones son **INMUTABLES** + +- En los programas funcionales no existe la nocion de posicion de memoria por lo cual, no existen instrucciones de asignacion. + + `X = ` es una **declaración** y no una asignacion, esto implica 2 cosas + + - significa que X puede reemplazar a la expresion en cualquier parte del programa. + - dentro del programa no puede existir nuevamente algo como `X = ` ya que `X` es `INMUTABLE` + +- Las funciones son `"first class citizens"` a diferencias de otros paradigmas, por ejemplo el OO donde las funciones solo pueden vivir como miembros de una clase o un objeto. En la programacion funcional las funciones son tratadas al mismo nivel de las clases y los objetos, es decir, pueden almacenarse como variables, pueden ser pasadas como parametros a funciones, pueden ser el resultado de una funcion. etc. + +- **Funciones de orden superior**: Las funciones pueden pasarse como parametro a otras funciones + +- **Fuertemente tipado y estatico**: + +- **Inferencia de tipo** el programador no esta obligado a declarar el tipo de las expresiones. (se infieren) + +- **Polimorfismo** + +- **Evaluacion perezosa**: las expresiones se llaman solo cuando se necesitan resolver. diff --git a/unidad_4/haskell/ejercicios/README.MD b/unidad_4/haskell/ejercicios/README.MD new file mode 100644 index 00000000..360a7c48 --- /dev/null +++ b/unidad_4/haskell/ejercicios/README.MD @@ -0,0 +1,29 @@ +# Ejercicios de Haskell + +## Funciones simples + +1. Escribir una funcion que dado un entero devuelva el sucesor. +2. Escribir una función en Haskell que devuelva el doble de un numero. +3. Escribir una función que devuelva el cuadruple de un numero, utilizando composicion de funciones y la funcion del punto anterior. +4. Escribir una función que devuelva un booleano indicando si un numero pasado como parámetro es par. +5. Escribir una funcion que tomado una tupla de numeros devuelva el mayor. +6. Escribir una funcion que dada una tupla de enteros, devuelva la division de dichos numeros +7. Escribir una funcion que dada una tupla de enteros devuelva una tupla con la division entera como primer miembro y el resto como segundo miembro de la tupla + +## Funciones condicionales o recursivas + +8. Hacer una función recursiva que devuelva el factorial de un numero. +9. Modificar la función anterior aplicando ajuste de patrones. +10. Escribir la funcion anterior pero con recursion final +11. Escribir una funcion que dada una tupla `(base, exponente)` devuelva la potencia exponente de la base. + +## Funciones de lista + +12. Escribir una funcion que dada una lista de elementos devuelva la longitud de dicha lista. `longitud` +13. Escribir una funcion que dada una lista de elementos devuelva la suma de los elementos de dicha lista. `sumatoria` +14. Escribir una funcion que devuelva el Maximo elemento de una lista `maximo` +15. Escribir una funcion que dada una lista y un numero. devuelva la lista con el elemento insertado al final. `push` +16. Escribir una funcion que dada una lista, filtre los elementos de la lista segun un criterio dada en una funcion. `customFilter` +17. Escribir una funcion que dada una funcion y una lista, aplique la funcion a todos los elementos de la lista. `customMap` +18. Escribir una funcion que pasada una un valor y una lista, devuelva la posicion en donde se encontro dicho elemento o -1 si no fue hallado. `indexOf` +19. Escribir una funcion que pasada un valor y una lista, devuelva Verdadero o Falso segun si el elemento existe en la lista. `exists` diff --git a/unidad_4/haskell/ejercicios/funciones.hs b/unidad_4/haskell/ejercicios/funciones.hs new file mode 100644 index 00000000..294b9b3b --- /dev/null +++ b/unidad_4/haskell/ejercicios/funciones.hs @@ -0,0 +1,61 @@ +module Funciones where + +{- Funciones iniciales -} + +-- 1. sucesor +sucesor :: Integer -> Integer +sucesor 2 = 4 +sucesor 4 = 8 +sucesor x = x + 1 + +pre :: Integer -> Integer +pre x = x - 1 + +-- 2. doble +doble :: Integer -> Integer +doble x = x*2 + +cuadruple :: Integer -> Integer +cuadruple x = doble(doble(x)) + +isPar :: Integer -> Bool +isPar x = x `mod` 2 == 0 + +isMayor :: Integer -> Bool +isMayor x = if x>= 18 then True else False + +mayor :: (Integer, Integer) -> Integer +mayor (x, y) = if x>=y then x else y + +division :: (Integer, Integer) -> Double +division (x,y) = fromInteger(x) / fromInteger(y) + + +factorial_a :: Integer -> Integer +factorial_a x = if ( x == 1 ) then 1 + else + x * factorial_a(x-1) + +factorial_b :: Integer -> Integer +factorial_b 0 = 1 +factorial_b x = x * factorial_b(x-1) + + +factorial_c :: Integer -> Integer +factorial_c 0 = 1 +factorial_c x = factorialAux(1, x, 1) + +factorialAux :: (Integer, Integer, Integer) -> Integer +factorialAux(it, base, tot) = if it > base then tot + else + factorialAux(it+1, base, tot*it) + +longitud :: [Integer] -> Integer +longitud [] = 0 +longitud (x:xs) = 1 + longitud(xs) + +customFilter(f, []) = [] +customFilter(f, x:xs) = if (f(x)== True)then + x : customFilter(f, xs) + else + customFilter(f, xs) \ No newline at end of file diff --git a/unidad_4/haskell/funciones.hs b/unidad_4/haskell/funciones.hs deleted file mode 100644 index 0d175c5c..00000000 --- a/unidad_4/haskell/funciones.hs +++ /dev/null @@ -1,43 +0,0 @@ -module Funciones where -sucesor :: Integer -> Integer -sucesor(x) = x + 1 - -pre :: Integer -> Integer -pre(x) = x - 1 - -doble :: Integer -> Integer -doble x=x+x - -cuadruple :: Integer -> Integer -cuadruple(x) = doble(doble(x)) - -isPar :: Integer -> Bool -isPar x = x `mod` 2 == 0 - -menor (x,y) = if x <= y then x else y - -{- funciones de lista -} - -customMap (f,[]) = [] -customMap (f,x:xs) = f(x) : customMap(f, xs) - -customFilter (f, []) = [] -customFilter (f, x:xs) = if f(x)==True then - x:customFilter(f, xs) - else - customFilter(f, xs) - -exists(el, []) = False -exists(el, x:xs) = if el == x then - True - else - exists(el, xs) - -indexOf(el, []) = -1 -indexOf(el, x:xs) = indexOfAux(el, x:xs, 0) - -indexOfAux(el, [], currIdx) = -1 -indexOfAux(el, x:xs, currIdx) = if(el == x) then - currIdx - else - indexOfAux(el, xs, currIdx+1) \ No newline at end of file diff --git a/unidad_4/javascript/funciones.js b/unidad_4/javascript/funciones.js deleted file mode 100644 index 03d7dd87..00000000 --- a/unidad_4/javascript/funciones.js +++ /dev/null @@ -1,12 +0,0 @@ - -const sucesor = (n) => n + 1; - -const doble = function (n) { - n + n; -}; - - -module.exports = { - sucesor, - doble -} \ No newline at end of file diff --git a/unidad_4/javascript/index.js b/unidad_4/javascript/index.js index ff2e2b45..64872555 100644 --- a/unidad_4/javascript/index.js +++ b/unidad_4/javascript/index.js @@ -1,15 +1,13 @@ -/* + const express = require("express"); const app = express(); const port = 3000; +app.use(express.static('public')); +app.use('/', express.static(__dirname + '/public')); + app.get("/", (req, res) => { - res.send("Bienvenidos 😎"); + // res.send(""); }); app.listen(port, () => console.log(`Servidor escuchando ${port}!`)); -*/ - -const funciones = require('./funciones') - -console.log(funciones.sucesor(1)); \ No newline at end of file diff --git a/unidad_4/javascript/public/funciones.js b/unidad_4/javascript/public/funciones.js new file mode 100644 index 00000000..1299b8ee --- /dev/null +++ b/unidad_4/javascript/public/funciones.js @@ -0,0 +1,29 @@ +function isPar(x){ + return x % 2 === 0 +} + +function sucesor(n){ + return n+1 +} + +function doble(n) { + return n + n +} + + +const isMayorEdad = function(edad){ + if( edad >= 18 ) + return true + else + return false +} + +const persona1 = { + apellido: 'Perez', + nombre: 'Juan', + anio_nac: 1988, + edad: function(){ + const currentYear = new Date().getFullYear() + return currentYear - this.anio_nac + } +} \ No newline at end of file diff --git a/unidad_4/javascript/public/index.html b/unidad_4/javascript/public/index.html index e69de29b..3e278c4e 100644 --- a/unidad_4/javascript/public/index.html +++ b/unidad_4/javascript/public/index.html @@ -0,0 +1,17 @@ + + + + + + Bienvenidos 😎 + + + + +
+

f12 o click derecho inspeccionar->consola

+
+ + + + \ No newline at end of file diff --git a/unidad_6/README.MD b/unidad_6/README.MD new file mode 100644 index 00000000..3b020bc0 --- /dev/null +++ b/unidad_6/README.MD @@ -0,0 +1 @@ +# Tecnologias Emergentes \ No newline at end of file diff --git a/unidad_6/padel/.env.js b/unidad_6/padel/.env.js new file mode 100644 index 00000000..67ab5dac --- /dev/null +++ b/unidad_6/padel/.env.js @@ -0,0 +1,13 @@ +export const environment = { + production: false, + firebase: { + apiKey: "AIzaSyAbYty3CiZT8PO1x6v2KKozICBx8nyGAUw", + authDomain: "amigosdelpadel-com-ar.firebaseapp.com", + databaseURL: "https://amigosdelpadel-com-ar.firebaseio.com", + projectId: "amigosdelpadel-com-ar", + storageBucket: "amigosdelpadel-com-ar.appspot.com", + messagingSenderId: "455570005506", + appId: "1:455570005506:web:8d153f5413eb7bd9d1511b", + measurementId: "G-EWDN05NYWY" + } +}; \ No newline at end of file diff --git a/unidad_6/padel/.firebaserc b/unidad_6/padel/.firebaserc new file mode 100644 index 00000000..881c0ba6 --- /dev/null +++ b/unidad_6/padel/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "amigosdelpadel-com-ar" + } +} diff --git a/unidad_6/padel/.gitignore b/unidad_6/padel/.gitignore new file mode 100644 index 00000000..dbb58ffb --- /dev/null +++ b/unidad_6/padel/.gitignore @@ -0,0 +1,66 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +firebase-debug.log* +firebase-debug.*.log* + +# Firebase cache +.firebase/ + +# Firebase config + +# Uncomment this if you'd like others to create their own Firebase project. +# For a team working on the same Firebase project(s), it is recommended to leave +# it commented so all members can deploy to the same project(s) in .firebaserc. +# .firebaserc + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env diff --git a/unidad_6/padel/404.html b/unidad_6/padel/404.html new file mode 100644 index 00000000..829eda8f --- /dev/null +++ b/unidad_6/padel/404.html @@ -0,0 +1,33 @@ + + + + + + Page Not Found + + + + +
+

404

+

Page Not Found

+

The specified file was not found on this website. Please check the URL for mistakes and try again.

+

Why am I seeing this?

+

This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html file in your project's configured public directory.

+
+ + diff --git a/unidad_6/padel/appLogin.js b/unidad_6/padel/appLogin.js new file mode 100644 index 00000000..b43b573a --- /dev/null +++ b/unidad_6/padel/appLogin.js @@ -0,0 +1,111 @@ +function registrar (){ + //console.log('Diste un clic') + var email = document.getElementById('email').value; + var clave = document.getElementById('clave').value; + console.log(email); + console.log(clave); + firebase.auth().createUserWithEmailAndPassword(email, clave) + .then(function(){ + //SOLO SE EJECUTA VERIFICAR PARA EL USUARIO QUE SE ESTA REGISTRANDO + verifcar() + }) + .catch(function(error) { + // Handle Errors here. + var errorCode = error.code; + var errorMessage = error.message; + console.log(errorMessage); + //alert(errorMessage); + + // ... + });email-clave.html +} + +function ingresar (){ + + var email = document.getElementById('email2').value; + var clave = document.getElementById('clave2').value; + firebase.auth().signInWithEmailAndPassword(email, clave) + .catch(function(error) { + // Handle Errors here. + var errorCode = error.code; + var errorMessage = error.message; + alert(errorMessage); + // ... + });email-clave.html + + +} + +function observador (){ + + + firebase.auth().onAuthStateChanged(function(user) { + if (user) { + // User is signed in. + console.log('Existe usuario activo'); + aparece(user); + var displayName = user.displayName; + var email = user.email; + console.log("ESTO ES PARA MOSTRAR LA VERIFICACION VIA MAIL"); + console.log(user.emailVerified); + var emailVerified = user.emailVerified; + var photoURL = user.photoURL; + var isAnonymous = user.isAnonymous; + var uid = user.uid; + var providerData = user.providerData; + // ... + } else { + // User is signed out. + console.log("usuario NO Logueda"); + + contenido.innerHTML = ` +
+ +
+ `; + + + // ... + } + });email-clave.html + +} + +function aparece(user){ + var contenido = document.getElementById('contenido'); + if (user.emailVerified){ + location.href="index.html"; + } +} + + +function cerrar(){ + firebase.auth().signOut() + .then(function(){ + console.log("Saliendo....") + }) + .catch(function(error){ + console.log(error) + }) +} + + +function verifcar(){ + //PARA CUALQUIER USER, VERIFICA ENVIANDO UN MAIL + //SOLO SE DEBERÍA EJECUTAR PARA EL USUARIO QUE SE ESTA REGISTRANDO + // VER CODIGO EN FUNCION REGISTRAR + var user = firebase.auth().currentUser; + user.sendEmailVerification().then(function() { + // email sent + console.log("Enviando correo...") + alert("Te hemos enviado un correo de activación"); + }).catch(function(error) { + // an error heppened + console.log(error) + }); +} + +observador(); diff --git a/unidad_6/padel/appPlayer.js b/unidad_6/padel/appPlayer.js new file mode 100644 index 00000000..540ad3b0 --- /dev/null +++ b/unidad_6/padel/appPlayer.js @@ -0,0 +1,167 @@ +//import { observador } from './appLogin.js'; +//const checkear = require('./appLogin.js'); +//observador(); +//console.log("app.js OK !!!") + +// Your web app's Firebase configuration + +firebase.initializeApp({ + apiKey: "AIzaSyAbYty3C2KKozICBx8nyGAUw", + authDomain: "amigosdelpadel.firebaseapp.com", + databaseURL: "https://amigosdelpadel.firebaseio.com", + projectId: "amigosdelpadel", + storageBucket: "amigosdelpadel.appspot.com", + messagingSenderId: "455505506", + appId: "1:45557506:web:8d153f7bd9d1511b", + measurementId: "G-EWD5NYWY" + }); + + // Initialize Firebase + var db = firebase.firestore(); + + function validacion(nombre, apellido, lado, fecha){ + console.log('Entro a Validar'); + if (nombre = null || nombre.length == 0 || /^\s+$/.test(nombre)) { + alert('[ERROR] El campo nombre debe tener un valor'); + //document.fvalida.nombre.focus() + return false; + } + else if (apellido = null || apellido.length == 0 || /^\s+$/.test(apellido)) { + alert('[ERROR] El campo apellido debe tener un valor'); + //document.fvalida.apellido.focus() + return false; + } + else if (lado=null || lado.length == 0 || /^\s+$/.test(lado)) { + alert('[ERROR] El campo Lado debe tener un valor'); + //document.fvalida.lado.focus() + return false; + } + else if (fecha=null || fecha.length == 0 || /^\s+$/.test(fecha)) { + alert('[ERROR] El campo Fecha debe tener un valor'); + //document.fvalida.fecha.focus() + return false; + } else { + //document.fvalida.submit(); + console.log('Validacion OK'); + return true; + } + // Si el script ha llegado a este punto, todas las condiciones + // se han cumplido, por lo que se devuelve el valor true + + } + + + + //Agrega un elemento a la collection User + function guardar(){ + + var nombre = document.getElementById('nombre').value; + var apellido = document.getElementById('apellido').value; + var lado = document.getElementById('lado').value; + var fecha = document.getElementById('fecha').value; + + if (validacion(nombre, apellido, lado, fecha)) { + console.log('entro al if del guardar'); + db.collection("users").add({ + first: nombre, + last: apellido, + side: lado, + born: fecha + }) + .then(function(docRef) { + console.log("Document written with ID: ", docRef.id); + document.getElementById('nombre').value = ''; + document.getElementById('apellido').value = ''; + document.getElementById('lado').value = ''; + document.getElementById('fecha').value = ''; + alert("Tus datos se registraron con Exito"); + }) + .catch(function(error) { + console.error("Error adding document: ", error); + }); + + } + } + + // Leer Registros + var tabla = document.getElementById('tabla'); + //Con GET cuando agrego un user NO actualiza en tiempo real. + //db.collection("users").get().then((querySnapshot) => { + // Para que actualice en tiempo real se debe reemplazar el GET por Snap + // ...tambien se debe eliminar el then, para evitar error en interprete + var f = new Date(); + //document.write(f.getDate() + "/" + (f.getMonth() +1) + "/" + f.getFullYear()); + + db.collection("users").onSnapshot((querySnapshot) => { + tabla.innerHTML=''; + querySnapshot.forEach((doc) => { + //console.log(`${doc.id} => ${doc.data()}`); + console.log(`${doc.id} => ${doc.data().first}`); + + tabla.innerHTML += ` + + ${doc.id} + ${doc.data().first} + ${doc.data().last} + ${doc.data().side} + ${doc.data().born} + + + + ` + }); + }); + + // ELiminar registros + // + function eliminar(id){ + db.collection("users").doc(id).delete().then(function() { + //console.log("id a eliminar: " + id); + console.log("Document successfully deleted!"); + }).catch(function(error) { + console.error("Error removing document: ", error); + }); + } + + //Actualizar registro + function editar(id, nombre, apellido, lado, fecha){ + document.getElementById('nombre').value = nombre; + document.getElementById('apellido').value = apellido; + document.getElementById('lado').value = lado; + document.getElementById('fecha').value = fecha; + var boton = document.getElementById('boton'); + boton.innerHTML = 'Editar'; + boton.onclick = function(){ + var washingtonRef = db.collection("users").doc(id); + // Set the "capital" field of the city 'DC' + var nombre = document.getElementById('nombre').value + var apellido = document.getElementById('apellido').value + var lado = document.getElementById('lado').value + var fecha = document.getElementById('fecha').value + if (validacion(nombre, apellido, lado, fecha)) { + console.log('entro al validar x Editar'); + return washingtonRef.update({ + //capital: true + first: nombre, + last: apellido, + side: lado, + born: fecha + }) + .then(function() { + console.log("Document successfully updated!"); + document.getElementById('nombre').value = ''; + document.getElementById('apellido').value = ''; + document.getElementById('lado').value = 'Drive'; + document.getElementById('fecha').value = ''; + boton.innerHTML = 'Guardar'; + alert("Tus datos se editaron con Exito"); + }) + .catch(function(error) { + // The document probably doesn't exist. + console.error("Error updating document: ", error); + }); + } + } + + + } \ No newline at end of file diff --git a/unidad_6/padel/database.rules.json b/unidad_6/padel/database.rules.json new file mode 100644 index 00000000..f54493db --- /dev/null +++ b/unidad_6/padel/database.rules.json @@ -0,0 +1,7 @@ +{ + /* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */ + "rules": { + ".read": false, + ".write": false + } +} \ No newline at end of file diff --git a/unidad_6/padel/firebase.json b/unidad_6/padel/firebase.json new file mode 100644 index 00000000..63c48c31 --- /dev/null +++ b/unidad_6/padel/firebase.json @@ -0,0 +1,13 @@ +{ + "database": { + "rules": "database.rules.json" + }, + "hosting": { + "public": ".", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + } +} diff --git a/unidad_6/padel/index.html b/unidad_6/padel/index.html new file mode 100644 index 00000000..7b2c14f5 --- /dev/null +++ b/unidad_6/padel/index.html @@ -0,0 +1,93 @@ + + + + + + + + + + + + Rancho Esther + + + + + + + + + + + + + + + + + +
+

Convocados para hoy 18hs:

+ + + + + + + + + + + + + + + + + + + + + + +
IdNombreApellidoLadoFechaEliminarEditar
+
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/unidad_6/padel/indexLogin.html b/unidad_6/padel/indexLogin.html new file mode 100644 index 00000000..3a468d91 --- /dev/null +++ b/unidad_6/padel/indexLogin.html @@ -0,0 +1,100 @@ + + + + + + Document + + + + + + + + + + + + + + +

Registro y Login

+ + + +
+ + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/unidad_6/padel/readme.md b/unidad_6/padel/readme.md new file mode 100644 index 00000000..88ffaab4 --- /dev/null +++ b/unidad_6/padel/readme.md @@ -0,0 +1,33 @@ +paso 1 ***************** + +Antes de utilizar cualquier servicio de Firebase, copia y pega estas secuencias de comandos en la parte inferior de la etiqueta : + + + + + + + + + + +paso 2 ***************** + + npm install -g firebase-tools + +paso 3 ***************** + +Puedes desplegarlo ahora o más adelante. Para hacerlo ahora, abre una ventana de terminal y accede al directorio "root" de la aplicación web (si no tienes uno, tendrás que crearlo). +Inicia sesión en Google + $firebase login +Inicia tu proyecto + +Ejecuta este comando desde el directorio "root" de tu aplicación: + $firebase init +Cuando tengas todo listo, despliega tu aplicación web + +Incluye los archivos estáticos (p. ej., HTML, CSS o JS) en el directorio de despliegue de tu aplicación, que se configura como "public" de forma predeterminada. Luego, ejecuta el siguiente comando desde el directorio "root" de la aplicación: + $firebase deploy + +Después del despliegue, consulta tu aplicación en amigosdelpadel-com-ar.web.app \ No newline at end of file diff --git a/unidad_6/tutoriales/Tutorial FB Crear Proyecto.pdf b/unidad_6/tutoriales/Tutorial FB Crear Proyecto.pdf new file mode 100644 index 00000000..65198c80 Binary files /dev/null and b/unidad_6/tutoriales/Tutorial FB Crear Proyecto.pdf differ diff --git a/unidad_6/tutoriales/ej1/Tutorial ON Hola Mundo desde FB.pdf b/unidad_6/tutoriales/ej1/Tutorial ON Hola Mundo desde FB.pdf new file mode 100644 index 00000000..66988bed Binary files /dev/null and b/unidad_6/tutoriales/ej1/Tutorial ON Hola Mundo desde FB.pdf differ diff --git a/unidad_6/tutoriales/ej1/ejMTI_1.html b/unidad_6/tutoriales/ej1/ejMTI_1.html new file mode 100644 index 00000000..b19a443e --- /dev/null +++ b/unidad_6/tutoriales/ej1/ejMTI_1.html @@ -0,0 +1,49 @@ + + + + + + + Primer Ejemplo Firebase + + + +

+ + + + + + + \ No newline at end of file diff --git a/unidad_6/tutoriales/ej1/solucion.html b/unidad_6/tutoriales/ej1/solucion.html new file mode 100644 index 00000000..97db401b --- /dev/null +++ b/unidad_6/tutoriales/ej1/solucion.html @@ -0,0 +1,46 @@ + + + + + + Document + + +

+ + + + + + + \ No newline at end of file diff --git a/unidad_6/tutoriales/ej2/Tutorial VALUE FB.pdf b/unidad_6/tutoriales/ej2/Tutorial VALUE FB.pdf new file mode 100644 index 00000000..6cf7aa7e Binary files /dev/null and b/unidad_6/tutoriales/ej2/Tutorial VALUE FB.pdf differ diff --git a/unidad_6/tutoriales/ej2/app.js b/unidad_6/tutoriales/ej2/app.js new file mode 100644 index 00000000..3252c5be --- /dev/null +++ b/unidad_6/tutoriales/ej2/app.js @@ -0,0 +1,39 @@ +console.log('Entro al app'); + +(function() { + + // PASO 3. Inicializar Firebase + const config = { + apiKey: "AIzaSyCJFDI8QQYSsB94MBBrtOo6o", + authDomain: "pylp.firebaseapp.com", + databaseURL: "https://pylp2.firebaseio.com", + projectId: "pylp", + storageBucket: "pylp2.appspot.com", + messagingSenderId: "15996538", + appId: "1:15930538:web:4c1e834d8ca8e7083" + + }; + firebase.initializeApp(config); + + // PASO 4. Obtener elementos + const preObject = document.getElementById('objeto'); + + // PASO 5. Crear Referencias + const dbRefObject = firebase.database().ref().child('curso'); + + /* PASO 6. En firebase/Realtime creamos un objeto con la siguiente estructura: + curso: { + "nombre": "BDA", + "Horas": 15, + "institucion": "UNNE - UNaM" + } + */ + + // PASO 7. Sincronizar cambios objeto por Consola + dbRefObject.on('value', snap => console.log(snap.val())); + + // PASO 8. Otra opción para mostrar en pantalla + dbRefObject.on('value', snap => {preObject.innerText = JSON.stringify(snap.val(),null, 3);}); + + + } ()); \ No newline at end of file diff --git a/unidad_6/tutoriales/ej2/index.html b/unidad_6/tutoriales/ej2/index.html new file mode 100644 index 00000000..b5c5edee --- /dev/null +++ b/unidad_6/tutoriales/ej2/index.html @@ -0,0 +1,18 @@ + + + + + Segundo Ejemplo Firebase + + + + + +
 
+ + + + + + + \ No newline at end of file diff --git a/unidad_6/tutoriales/ej3/Tutorial CHILD FB.pdf b/unidad_6/tutoriales/ej3/Tutorial CHILD FB.pdf new file mode 100644 index 00000000..82ce919d Binary files /dev/null and b/unidad_6/tutoriales/ej3/Tutorial CHILD FB.pdf differ diff --git a/unidad_6/tutoriales/ej3/app.js b/unidad_6/tutoriales/ej3/app.js new file mode 100644 index 00000000..bfc5462b --- /dev/null +++ b/unidad_6/tutoriales/ej3/app.js @@ -0,0 +1,34 @@ +(function() { + + //Inicializar Firebase + const config = { + apiKey: "AIzaSyCJFDI8QQYSsB94MBBrtOo6o", + authDomain: "pylp.firebaseapp.com", + databaseURL: "https://pylp2.firebaseio.com", + projectId: "pylp", + storageBucket: "pylp2.appspot.com", + messagingSenderId: "15996538", + appId: "1:15930538:web:4c1e834d8ca8e7083" + }; + firebase.initializeApp(config); + + //Obtener elementos + const preObject = document.getElementById('objeto'); + // PASO 3. + const ulList = document.getElementById('lista'); + + //Crear Referencias + const dbRefObject = firebase.database().ref().child('curso'); + // PASO 4. + const dbRefList = dbRefObject.child('alumnos'); + + // Sincronizar cambios objeto + //dbRefObject.on('value', snap => {preObject.innerText = JSON.stringify(snap.val(),null, 3);}); + // PASO 5. + //Sincronizar los elemento añadidos en la lista + dbRefObject.on('child_added', snap => console.log(snap.val())); + + // PASO 6. Visualizar objeto en el navegador. + dbRefList.on('value', snap => {ulList.innerText = JSON.stringify(snap.val(),null, 3);}); + + } ()); \ No newline at end of file diff --git a/unidad_6/tutoriales/ej3/index.html b/unidad_6/tutoriales/ej3/index.html new file mode 100644 index 00000000..a7a146dc --- /dev/null +++ b/unidad_6/tutoriales/ej3/index.html @@ -0,0 +1,19 @@ + + + + + Tercer Ejemplo Firebase + + + + + +
 
+ + +
 
+ + + + + \ No newline at end of file diff --git a/unidad_6/tutoriales/hostingFirebase.txt b/unidad_6/tutoriales/hostingFirebase.txt new file mode 100644 index 00000000..3e941ef2 --- /dev/null +++ b/unidad_6/tutoriales/hostingFirebase.txt @@ -0,0 +1,15 @@ +intalar node + https://github.com/nodesource/distributions/blob/master/README.md#debinstall +curl -sL https://firebase.tools | bash +sudo npm install -g firebase-tools +firebase login o firebase login:ci o + firebase login --reauth + firebase projects:list +firebase init + +// antes de hacer el deploy copiar index.html y app.js al dir "public" +firebase deploy + + + +https://ejemplomti2022.web.app/