<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alejandro Fuentes on Medium]]></title>
        <description><![CDATA[Stories by Alejandro Fuentes on Medium]]></description>
        <link>https://medium.com/@alejandrofuentesar?source=rss-891474d3ec4e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6757tNrGjbsOgOM6c8Mwvw.jpeg</url>
            <title>Stories by Alejandro Fuentes on Medium</title>
            <link>https://medium.com/@alejandrofuentesar?source=rss-891474d3ec4e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 09:25:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alejandrofuentesar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[DevOps | How I Fixed AWS’s “Unprotected Private Key File” SSH Error]]></title>
            <link>https://medium.com/@alejandrofuentesar/devops-how-i-fixed-awss-unprotected-private-key-file-ssh-error-913e0a23c58d?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/913e0a23c58d</guid>
            <category><![CDATA[ssh-keys]]></category>
            <category><![CDATA[ssh]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Sat, 14 Jun 2025 22:28:48 GMT</pubDate>
            <atom:updated>2025-06-14T22:28:48.433Z</atom:updated>
            <content:encoded><![CDATA[<h4>The Frustration</h4><p>I generated a shiny new .pem key in AWS, downloaded it, and tried to SSH into my EC2 instance—only to be blocked by this:</p><pre>@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@<br>@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @<br>Permissions 0644 for &#39;ssh-aws-bootcamp.pem&#39; are too open.</pre><h4>Why ?</h4><p>AWS (and SSH) require strict file permissions for private keys. Default downloads often set permissions to -rw-r--r-- (644), which SSH considers <strong>too exposed</strong>.</p><h4>How to solve ?</h4><p>One command saved me:</p><pre>chmod 400 ssh-aws-bootcamp.pem  </pre><p>This changes permissions to -r-------- (400), meaning:</p><ul><li><strong>Only the owner can read</strong> the file.</li><li>No accidental edits or leaks.</li></ul><h4>Why This Matters</h4><ul><li><strong>Security:</strong> Private keys must stay private. Loose permissions could allow unauthorized access.</li><li><strong>AWS Compliance:</strong> EC2 instances enforce this to prevent credential misuse.</li></ul><h4>Verifying the Fix</h4><p>After running chmod, I connected successfully:</p><pre>ssh -i ssh-aws-bootcamp.pem ec2-user@&lt;you-ip-instance&gt;  </pre><p>And voilà — access granted!</p><blockquote>💡 T<strong>ip:</strong> Always set permissions <em>immediately</em> after downloading a .pem file.</blockquote><h3>Conclusion</h3><p>Security is important, and we need to respect it. Today I learned one of the many things AWS does to protect their connections.</p><p>thanks for ask me !</p><p><strong><em>ale(ai)-coop</em></strong><em> : for transparency, this post includes content generated with the assistance of the AI model. </em>🤖</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=913e0a23c58d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Short Post | How I Use Claude AI to Generate Code and Commands]]></title>
            <link>https://medium.com/@alejandrofuentesar/short-post-how-i-use-claude-ai-to-generate-code-and-commands-d988e19e6847?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/d988e19e6847</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[claude-ai]]></category>
            <category><![CDATA[generative-ai-use-cases]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Sun, 18 May 2025 17:02:31 GMT</pubDate>
            <atom:updated>2025-05-18T17:02:31.931Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/871/1*Ux7q02zlmYPTQYqODtw5AA.png" /></figure><p>Hi, I make this post for me, a very short post, talking about AI Generative, etc. But, I first questions that all people get when listen AI…</p><blockquote><em>What is generative AI ?</em></blockquote><p>Unlike the intelligence that humans naturally possess, <strong>AI </strong>is artificially constructed. It learns from vast amounts of data and experience to generate outcomes intended to mimic or approximate human-like intelligence.</p><p><strong>Generative AI</strong> represents an exciting evolution of artificial intelligence. It goes beyond simply retrieving information; instead, it synthesizes new possibilities, crafting unique responses tailored to your specific needs. Think of it as AI with the ability to generate personalized answers based on the subtleties of your questions.</p><p>For instance, while generative AI can explain the intricacies of the AWS CLI Shell, like the command to create an S3 bucket (aws s3api create-bucket), its true power for a cloud architect shines when considering automation. Knowing how to leverage shell scripting allows you to take that knowledge and build robust, repeatable workflows to manage your cloud resources efficiently. So, while AI provides the &#39;what,&#39; your scripting skills empower the &#39;how&#39; of automation in the cloud.</p><h3>Claude, help me?</h3><p>Understanding <strong>prompts </strong>is another key area to learn for a better experience. However, in this post, I’ll keep things simple. Next my prompt :</p><pre>Provide practical examples related to the use of the AWS S3 Storage service, <br>using the command line (CLI) in AWS Cloud Cloud Shell. <br>Include example commands for:<br><br>1. Creating a new bucket.<br>2. Listing existing buckets.<br>3. Uploading files to a bucket.<br>4. Downloading files from a bucket.<br>5. Listing the contents of a bucket.<br>6. Moving or renaming a file within a bucket.<br>7. Deleting a file from a bucket.<br>8. Deleting a bucket and its contents.</pre><p>Wow, Claude answer me… I’ll testing it now</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7i4hN_uNO3PY4p1n7v7Exg.png" /></figure><h3>My step by step…</h3><p>01 | create a bucket, create a bucket named “my-example-bucket” in the us-east-1 region</p><pre>aws s3 mb s3://my-example-bucket --region us-east-1</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ACaPFGYrkRpFEEVES6kH4g.png" /></figure><p>02 | List all your S3 buckets</p><pre>aws s3 ls</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/510/1*DVO1qoXsctnCo-O8kLOj9w.png" /></figure><p>03 | Upload a single file</p><pre>aws s3 cp myfile.txt s3://my-example-bucket/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJOGalM4edU93H2SfgZspw.png" /></figure><p>04 | Download a single file</p><pre>aws s3 cp s3://my-example-bucket/myfile.txt ./</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yS8rzaOxU6yZxbx_KMGzaw.png" /></figure><p>05 | List all objects in a bucket</p><pre>aws s3 ls s3://my-example-bucket/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/499/1*Kt4q9HhJMolHtHAWoO3mig.png" /></figure><p>06 | Move/rename a file</p><pre>aws s3 mv s3://my-example-bucket/oldname.txt s3://my-example-bucket/newname.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*30YeMckJDYx-mFwhxh_TAw.png" /></figure><p>07 | Delete a single file</p><pre>aws s3 rm s3://my-example-bucket/myfile.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/631/1*j3odYV_D51mrK_ZbaR-DOQ.png" /></figure><p>08 | Deleting a bucket and its contents</p><pre># First, remove all objects in the bucket<br>aws s3 rm s3://my-example-bucket/ --recursive<br><br># Then delete the empty bucket<br>aws s3 rb s3://my-example-bucket<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*G9zVDNCuFSXKgwLIU-654w.png" /></figure><h3>Conclusion with my coworker Claude</h3><p>Ultimately, utilizing Claude as a co-pilot is a powerful way to learn and explore the capabilities of generative AI. However, it’s essential to remember the importance of human oversight. Prioritize ethical considerations, meticulously verify any generated information or code, and always conduct thorough testing before deployment. Claude is a valuable assistant, but your critical thinking and expertise are the final authority — you are the pilot.</p><p>Tanks …</p><p><strong><em>ale(ai)-coop</em></strong><em> : for transparency, this post includes content generated with the assistance of the AI model.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d988e19e6847" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS | Una solución IDE]]></title>
            <link>https://medium.com/@alejandrofuentesar/aws-una-soluci%C3%B3n-ide-8c8247536aaa?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c8247536aaa</guid>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Sat, 09 Nov 2024 15:21:45 GMT</pubDate>
            <atom:updated>2025-05-25T12:05:08.284Z</atom:updated>
            <content:encoded><![CDATA[<h3>AWS | Una solución usando VSCode</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*2V7yYz6DFxfQh5jSbHcDSg.png" /></figure><blockquote>Después de una cuidadosa consideración, decidimos cerrar el acceso de nuevos clientes a AWS Cloud9, con efecto a partir del 25 de julio de 2024. Los clientes existentes de AWS Cloud9 pueden continuar utilizando el servicio normalmente. AWS sigue invirtiendo en mejoras de seguridad, disponibilidad y rendimiento para AWS Cloud9, pero no planeamos introducir nuevas funcionalidades.</blockquote><p>Esto fue el mensaje que el equipo de AWS compartió después de tomar la decisión de no ofrecer el servicio Cloud9 a nuevos clientes. El link <a href="https://aws.amazon.com/blogs/devops/how-to-migrate-from-aws-cloud9-to-aws-ide-toolkits-or-aws-cloudshell/">aqui</a>.</p><p>Vamos a tomar la iniciativa de crear nuestra EC2 para poder utilizarla como una alternativa a Cloud9.</p><h3>Pero, que és Cloud9?</h3><p>AWS Cloud9 es un IDE basado en la nube que permitía la codificación colaborativa dentro de una interfaz basada en navegador.</p><p>Si bien Cloud9 era fácil de usar, los nuevos usuarios de AWS ya no podrán aprovechar este beneficio.</p><p>Pero podemos crear nuestra solución IDE, voy a compartir cómo lo hice.</p><h3>Configuración de un Entorno de Desarrollo con una Instancia EC2</h3><p>Vamos a dividir en una receta que será la siguiente</p><ul><li>Paso 1: Instalar VSCode en nuestra terminal</li><li>Paso 2: Crear una instancia EC2</li><li>Paso 3: Conectar a la instancia EC2 con VSCode</li><li>Paso 4: Testando con Node</li></ul><h3>Paso 1 — Instalar VSCode en nuestra terminal</h3><p>Para agregar este IDE es simple, basta con googlear VSCode, ir a la página principal, hacer download e instalar. El link <a href="https://code.visualstudio.com/">aqui (VSCode)</a>.</p><p>Después de instalar, añade el siguiente plugin: <a href="https://www.notion.so/53e3d4c384784ad79fee3a3cc7006495?pvs=21">Remote-SHH</a>, cuyo propietario es Microsoft.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*16WrMRSYMy-1q0BGyI2dUg.png" /></figure><p>Su función será ayudarnos a conectarnos con nuestra instancia AWS por medio de una conexión SSH.</p><h3>Paso 2 — Crear una instancia EC2</h3><p>Crear una instancia EC2La creación de la instancia dependerá de cuál perfil de usuario o tier eres, pero los pasos son los siguientes (utilizaré en el ejemplo la consola de AWS, y las descripciones de los menús en inglés):</p><ol><li>Ir a la consola de AWS (<a href="https://console.aws.amazon.com/">https://console.aws.amazon.com/</a>)</li><li>Buscar el servicio EC2, puedes utilizar la barra de búsqueda que esta en la parte superior.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yozn5TdFGkL2qqIwD6z5ow.png" /></figure><p>3. Seleciona la opción <strong>Launch Instances</strong>, para iniciar con la creación de una nueva instancia.</p><p>4. En la creación de la instancia utilice los siguiente datos (buscando el tipo Free Tier):</p><ul><li>instance image: Amazon Linux (user: ec2-user) | Ubuntu (user: ubuntu)</li><li>instance type: t2.micro</li><li>instance SSH Key: usei el nombre vscode-key | formato .pem → En este paso vamos a salvar el archivo .pem en una pasta fácil de acessar, para el paso 5, donde testaremos la conexión, en mi ejemplo estará en la carpeta ssh-keys.</li><li>Security Groups: Allow SSH traffic</li></ul><p>Finalizo, y espero que la instancia este creada.</p><p>5. Testar la conexión SSH desde la línea de comando:</p><ul><li>Copie la dirección <strong>Public IPV4 DNS</strong> que será útil para la conexión</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u6sH-F73zbvTPa6nYyMRyA.png" /></figure><ul><li>me hubico en la pasta ssh-keys donde salve el archivo .pem</li></ul><pre>cd ssh-keys <br>ls / dir <br>ssh -i vscode-key.pem ec2-user@[aqui-la-IPv4-DNS-publica-de-tu-istancia]</pre><p>Una observación sobre los archivos de seguridad como .pem: AWS no permite la lectura de estos archivos si sus permisos son muy abiertos, es decir, si cualquier usuario puede acceder, ya que considera que no sería un archivo seguro (tiene sentido, ya que recordemos que ese archivo se usa como llave para el acceso a SSH para la plataforma AWS). En caso de que sea el caso, utiliza los siguientes comandos para configurar el acceso solamente para el usuario que se conectará:</p><pre># caso esteja utilizando Linux/MacOS, o bash como GitBash <br>chmod 400 vscode-key.pem  <br><br># pero se estas utilizando Windows <br>icacls vscode-key.pem /inheritance:r <br>icacls vscode-key.pem /grant:r &quot;%username%&quot;:&quot;(R)&quot;</pre><h3>Paso 3 — Conectar a la instancia EC2 com VSCode</h3><p>Para este paso, utilizaremos al plugin <strong>Remote — SSH</strong> de VSCode.</p><p>Vamos a obtener el comando de conexión, es en la consola de AWS, selecionar nuestra instancia EC2, seguido el boton <strong>Connect</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3ulgWUG6_RUpFSQyallWyQ.png" /></figure><p>Después selecionamos el icono para copiar el comando</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*v9cJs4L-G5KJUve13cDGmA.png" /></figure><p>Ya con el comando en el clipboard, voy a VSCode, y seleciono adicionar una nueva conexión</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0QkH4UCeY_5rKTYvaUgzrw.png" /></figure><p>A seguir, es selecionar el tipo de sistema operativo de nuestra instancia, en mi caso <strong>Linux</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GB37Nn9h9Q6MCn8c0mMwqw.png" /></figure><p>Despues de un tiempo, la conexion es realizada</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/504/1*0fXwhnG9MpUaobpgnSET8g.png" /></figure><h3>Paso 4 — Testando con Node</h3><p>Aquí tienes un pequeño script en Node.js que puedes ejecutar en tu instancia EC2 y luego conectarte a ella desde Visual Studio Code.</p><p>Verifica si tenemos Node instalado. Para este caso, voy a utilizar NVM, ya que me permite administrar diferentes versiones de Node según el proyecto que esté utilizando. Para eso voy a compartir unos pasos que obtuve en <a href="https://www.freecodecamp.org/news/node-version-manager-nvm-install-guide/">este articulo</a> de Dillion Megida.</p><pre># instalar nvm en nuestra instancia<br>$ curl -o- &lt;https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh&gt; | bash</pre><pre># reiniciar la terminal<br># verificar al instalacion consultando la version<br>$ nvm -v<br>0.39.1</pre><pre># voy instalar la version &#39;v16.20.2&#39; (Latest LTS: Gallium)<br>$ nvm install v16.20.2<br>Downloading and installing node v16.20.2...<br>Downloading &lt;https://nodejs.org/dist/v16.20.2/node-v16.20.2-linux-x64.tar.xz&gt;...<br>############################################################# 100.0%<br>Computing checksum with sha256sum<br>Checksums matched!<br>Now using node v16.20.2 (npm v8.19.4)<br>Creating default alias: default -&gt; v16.20.2</pre><pre># definir la version &#39;v16.20.2&#39; para usar<br>$ nvm use v16.20.2<br>Now using node v16.20.2 (npm v8.19.4)</pre><pre># verificar si node esta activo<br>$ node -v<br>v16.20.2</pre><p>Abrir la pasta donde iremos crear nuestro projeto</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SdVvORaLSK4hP7JJcjYDIA.png" /></figure><p>Crear una pasta para trabajo de teste y un archivo .js:</p><pre>$ mkdir my-test<br>$ cd my-test/<br>$ touch hello.js</pre><p>Abrir nuestro archivo <strong>hello.js</strong> para editarlo</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UfunX-F15e5AyzNcC0DfVA.png" /></figure><p>Codar un ejemplo simples, y ejecutar</p><pre>// hello.js by alefuentes<br>function sayHello(name) {<br>    return `Hello, ${name}! Welcome to AWS EC2 via SSH.`;<br>}<br>const greeting = sayHello(&#39;Ale&#39;);<br>console.log(greeting);<br><br>// para ejecutar node hello.js</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*Joh8_HMEZxJs9k5HY2RnOA.png" /></figure><h3>Conclusion</h3><p>¡Con estos pasos y ejemplos, estarás listo para configurar Visual Studio Code con Remote SSH y trabajar en tu instancia EC2 en AWS de forma remota!</p><p>Si necesitas más ayuda o tienes alguna pregunta, ¡no dudes en decírmelo! <a href="https://www.instagram.com/ale_fuuuu/">ale_fuuuu</a><br><a href="https://www.instagram.com/p/DCJ_qb7RfHnMCuq72jsNC8GPBeOgddXcB4mHQY0/">Post-Instagram</a></p><p>¡Feliz codificación! 🚀👨‍💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c8247536aaa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IA | Knowing Ollama]]></title>
            <link>https://medium.com/@alejandrofuentesar/ia-knowing-ollama-08068258f296?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/08068258f296</guid>
            <category><![CDATA[ollama]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Fri, 29 Mar 2024 16:29:34 GMT</pubDate>
            <atom:updated>2024-03-29T16:29:34.835Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*YHX2MkNwICGgpm4-OC5EpA.jpeg" /></figure><p>In this post, I show you how I can use Ollama in my localhost PC. But before that, I do need to know what is Ollama?</p><h3>Ollama</h3><p>This tool allows us to run open-source large language models (LLMs), such as Llama 2, Gemma, on so on, locally. It optimizes setup and configuration details, including GPU usage.</p><p>See the <a href="https://ollama.com/download">Ollama download</a> to learn how to install Ollama on our PC.</p><p>See the <a href="https://ollama.com/library">Ollama Model Library</a> to know other model LLMs.</p><h3>Try use Ollama in my PC</h3><p>To install this tool is easy, only go to the download section and select what OS we want to use</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/459/1*gnwmSmIQfOHoLw11HVtcUg.png" /></figure><p><strong>INSTALL</strong></p><p>In my case I use Linux, but other OS is very easy too !!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-hIty_TgzOUA9DFIZ-d_jA.png" /></figure><blockquote><strong>OBS.</strong> if not run, you can use ollama start</blockquote><p>To see if ok, we can verify the Ollama version:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/381/1*PyGFztGDVIiCJmGkjBYFMA.png" /></figure><p><strong>USE MODEL LLAMA-2</strong></p><p>After installing and verify is okay, I going to try one LLM, I selected Llama-2</p><blockquote><strong>OBS</strong>. has several versions where the principal difference is the size of Gb, in my testing I use the default LLM, where your size is the smallest.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gb-wqkIzv-1IKpp-PMg93Q.png" /><figcaption>after that Ollama downloaded the Llama2&#39;s image, my command line was ready to read my questions</figcaption></figure><p>Then, I test with a simple question:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8reXrS2ZuVlfRBas-ByAyg.png" /></figure><p>To Finish the section, use the next command:</p><pre>/bye</pre><p>Now, I try with another LLM, the <a href="https://ollama.com/library/codellama">codelama</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*hKVDM4QygH91F6S2dbF0fg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oPuqNU1gFk6TA_s0FbOPfQ.png" /></figure><h3>Manage Ollama images</h3><p>Some command line</p><pre># -------------------------<br># see al images LLMs<br>❯ ollama list<br>NAME                    ID              SIZE    MODIFIED<br>codellama:latest        8fdf8f752f6e    3.8 GB  6 minutes ago<br>llama2:latest           78e26419b446    3.8 GB  21 minutes ago<br><br># -------------------------<br># remove image<br>❯ ollama rm llama2<br>deleted &#39;llama2&#39;<br><br>❯ ollama list<br>NAME                    ID              SIZE    MODIFIED<br>codellama:latest        8fdf8f752f6e    3.8 GB  9 minutes ago</pre><h3>UI with Ollama</h3><p>Ollama gives us one port for communication, the 11434 port. (<em>it’s important because now know our Ollama base URL</em>)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/266/1*fHzd8YbjJAip8oZYVt0fVQ.png" /></figure><p>Now, we can get a layout of the same Chat-Gpt for use with our ollama tools. The <a href="https://openwebui.com/">Open WebUI</a> is who helps us with it.</p><p>We go to use this image <a href="https://github.com/open-webui/open-webui/pkgs/container/open-webui">open-webui</a>.</p><pre>docker run -d -p 3000:8080 -e OLLAMA_BASE_URL=http://127.0.0.1:11434 -v open-webui:/app/backend/data --name open-webui --restart always ghcr.io/open-webui/open-webui:main<br><br># -p 3000:8080 : for container can see localhost net<br># -e OLLAMA_BASE_URL=https://127.0.0.1:11434 : is where our OLLAMA is running<br># -v open-webui:/app/backend/data : volume, where Open WebUi save data<br># --name open-webui : the name of our container<br># --restart always : if some thing is wrong, the container restar automatically<br># ghcr.io/open-webui/open-webui:main : imagen of Open WebUI to use.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iD_zni33s3wKQM9J6NR3GQ.png" /></figure><p>After running this image docker, we can test on <a href="http://127.0.0.1:3000.">http://127.0.0.1:3000.</a></p><p>Need create one user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C4c3CyDUse3y5Mhnx2Owkg.png" /></figure><p>Next, we need to select our LLM, in this case codellama.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j6dlj8MJS01VdNmGBAfWTQ.png" /></figure><p>Now, one test:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBZ9WM6CvLyuwSQCJtYoKw.png" /></figure><h3>Finish</h3><p>This example is how we can use models of IA in our PC. I think is a good tool for everyone who wants to learn, improve, study, etc their skills.</p><p>Thanks for reading me.</p><p>Atte.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=08068258f296" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GIT | Some tips for good practice II]]></title>
            <link>https://medium.com/@alejandrofuentesar/git-some-tips-for-good-practice-ii-721376eeb624?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/721376eeb624</guid>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Mon, 27 Nov 2023 23:16:46 GMT</pubDate>
            <atom:updated>2023-11-27T23:16:46.981Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*nbx6g2OEkHfpJfg18bpCBw.png" /></figure><p>To see the first post please click on <a href="https://medium.com/@alejandrofuentesar/git-some-tips-for-good-practice-a4eeac817c95">Git | Some tips for good practice</a>.</p><h3>HandsOn</h3><h4>Several files for different commits</h4><p>Ok, I started like a warrior and I making several tips in my current branch, but, when I need to commit it, ups! I need to separate these files into different commits, but, How do I do it?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*t2lzhe942tFydwd4Ddcbdg.png" /></figure><p>See my situation</p><pre># create my workdirectory<br>❯ mkdir test-commit-1<br>❯ cd test-commit-1<br><br># create my project files<br>❯ touch index.html &amp;&amp; touch index.css &amp;&amp; touch main.js &amp;&amp; touch connect.js &amp;&amp; touch README.md<br>❯ ll<br>total 0<br>-rw-r--r-- 1 alefu alefu 0 Nov 27 19:09 README.md<br>-rw-r--r-- 1 alefu alefu 0 Nov 27 19:09 connect.js<br>-rw-r--r-- 1 alefu alefu 0 Nov 27 19:09 index.css<br>-rw-r--r-- 1 alefu alefu 0 Nov 27 19:09 index.html<br>-rw-r--r-- 1 alefu alefu 0 Nov 27 19:09 main.js<br><br># start git in my workdirectory<br>❯ git init<br>Initialized empty Git repository in /home/alefu/study/devops/git/topic-repo/test-commit-1/.git/<br><br># see status<br>❯ git status<br>On branch master<br><br>No commits yet<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        README.md<br>        connect.js<br>        index.css<br>        index.html<br>        main.js<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)<br><br># add all files in my &#39;stage area&#39;<br>❯ git add .<br><br># ups! all files togheters<br>❯ git status<br>On branch master<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   README.md<br>        new file:   connect.js<br>        new file:   index.css<br>        new file:   index.html<br>        new file:   main.js</pre><p>If I want to remove one file is easy, use the command reset — &lt;name of file&gt; .</p><pre># see my status<br>❯ git status<br>On branch master<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   README.md<br>        new file:   connect.js<br>        new file:   index.css<br>        new file:   index.html<br>        new file:   main.js<br><br><br># I want to remove the README.md file<br>❯ git reset -- README.md<br><br># see status<br>❯ git status<br>On branch master<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   connect.js<br>        new file:   index.css<br>        new file:   index.html<br>        new file:   main.js<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        README.md<br><br># OK, now can commit without README.md file</pre><p>But, when has several files, is boring to write each file’s name that I don’t commit. But ok, We can use another command git add -i .</p><p>The -i param means <em>iterative</em> then when I can select more easily what file I want to revert.</p><pre>       -i, --interactive<br>           Add modified contents in the working tree interactively to the index. Optional path arguments may be supplied to limit operation<br>           to a subset of the working tree. See “Interactive mode” for details.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/989/1*P-qnLjnQMucz8DlPk7Hf_A.png" /></figure><pre>❯ git add -i<br>           staged     unstaged path<br>  1:        +0/-0      nothing README.md<br>  2:        +0/-0      nothing connect.js<br>  3:        +0/-0      nothing index.css<br>  4:        +0/-0      nothing index.html<br>  5:        +0/-0      nothing main.js<br><br>*** Commands ***<br>  1: status       2: update       3: revert       4: add untracked<br>  5: patch        6: diff         7: quit         8: help<br>What now&gt; 3<br>           staged     unstaged path<br>  1:        +0/-0      nothing README.md<br>  2:        +0/-0      nothing connect.js<br>  3:        +0/-0      nothing index.css<br>  4:        +0/-0      nothing index.html<br>  5:        +0/-0      nothing main.js<br>Revert&gt;&gt; 1<br>           staged     unstaged path<br>* 1:        +0/-0      nothing README.md<br>  2:        +0/-0      nothing connect.js<br>  3:        +0/-0      nothing index.css<br>  4:        +0/-0      nothing index.html<br>  5:        +0/-0      nothing main.js<br>Revert&gt;&gt; 2<br>           staged     unstaged path<br>* 1:        +0/-0      nothing README.md<br>* 2:        +0/-0      nothing connect.js<br>  3:        +0/-0      nothing index.css<br>  4:        +0/-0      nothing index.html<br>  5:        +0/-0      nothing main.js<br>Revert&gt;&gt; 3<br>           staged     unstaged path<br>* 1:        +0/-0      nothing README.md<br>* 2:        +0/-0      nothing connect.js<br>* 3:        +0/-0      nothing index.css<br>  4:        +0/-0      nothing index.html<br>  5:        +0/-0      nothing main.js<br>Revert&gt;&gt; 4<br>           staged     unstaged path<br>* 1:        +0/-0      nothing README.md<br>* 2:        +0/-0      nothing connect.js<br>* 3:        +0/-0      nothing index.css<br>* 4:        +0/-0      nothing index.html<br>  5:        +0/-0      nothing main.js<br>Revert&gt;&gt; # When want finish, only press Enter<br>rm &#39;README.md&#39;<br>rm &#39;connect.js&#39;<br>rm &#39;index.css&#39;<br>rm &#39;index.html&#39;<br>reverted 4 paths<br><br>*** Commands ***<br>  1: status       2: update       3: revert       4: add untracked<br>  5: patch        6: diff         7: quit         8: help<br>What now&gt; 4</pre><p>Ups, the file connect.js I want to commit but don’t worry, with option 4, I can add my stage area .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K_xRpsYGOCr3T5PZEpeKYA.png" /></figure><pre>*** Commands ***<br>  1: status       2: update       3: revert       4: add untracked<br>  5: patch        6: diff         7: quit         8: help<br>What now&gt; 4<br>  1: README.md<br>  2: connect.js<br>  3: index.css<br>  4: index.html<br>Add untracked&gt;&gt; 2<br>  1: README.md<br>* 2: connect.js<br>  3: index.css<br>  4: index.html<br>Add untracked&gt;&gt;<br>added 1 path<br><br>*** Commands ***<br>  1: status       2: update       3: revert       4: add untracked<br>  5: patch        6: diff         7: quit         8: help<br>What now&gt; q  # for exit use the key &#39;q&#39;<br>Bye.<br><br># see status of my workdirectory<br>❯ git status<br>On branch master<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   connect.js<br>        new file:   main.js<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        README.md<br>        index.css<br>        index.html</pre><p>Well, now I will add in my git repository my project correctly</p><pre># commit my javascript files<br>❯ git commit -m &#39;add javascript&#39;<br>[master (root-commit) bd14411] add javascript<br> 2 files changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 connect.js<br> create mode 100644 main.js<br><br># now, add index files<br>❯ git add index.*<br>❯ git status<br>On branch master<br>Changes to be committed:<br>  (use &quot;git restore --staged &lt;file&gt;...&quot; to unstage)<br>        new file:   index.css<br>        new file:   index.html<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        README.md<br><br># commit index files<br>❯ git commit -m &#39;add index files&#39;<br>[master 40b2e2a] add index files<br> 2 files changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 index.css<br> create mode 100644 index.html<br><br># now, add README file<br>❯ git add .<br>❯ git commit -m &#39;add README file&#39;<br>[master 2bfa94f] add README file<br> 1 file changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 README.md<br><br># see log with several commit agroup for files type<br>❯ git log --oneline<br>2bfa94f (HEAD -&gt; master) add README file<br>40b2e2a add index files<br>bd14411 add javascript<br></pre><h4>Several contents in one file for different commits</h4><p>Good, in this example, I write several pieces of information in one file, but each content needs to go in a different commit.</p><pre># edit commit with some content with any editor<br>❯ cat README.md<br># Project GIT<br><br>This project is for tutorial<br>of GIT and some commands.<br><br>I need add author and<br>more description or history.<br><br>11/27/2023<br><br># see status of my workdirectory<br>❯ git status<br>On branch master<br>Changes not staged for commit:<br>  (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)<br>  (use &quot;git restore &lt;file&gt;...&quot; to discard changes in working directory)<br>        modified:   README.md<br><br>no changes added to commit (use &quot;git add&quot; and/or &quot;git commit -a&quot;)<br><br># and commit for my git repository, in this case use param &#39;-am&#39; for add comment befor to commit<br>❯ git commit -am &#39;start content README file&#39;<br>[master 1f0ec5f] start content README file<br> 1 file changed, 9 insertions(+)<br><br>test-commit-1 on  master via  v10.19.0<br>❯ git status<br>On branch master<br>nothing to commit, working tree clean</pre><p>Ok, now for the test, editing the README.md file</p><pre>❯ cat README.md<br># Project GIT<br><br>This project is for tutorial<br>of GIT and some commands.<br><br>I need add author and<br>more description or history.<br><br>11/27/2023</pre><p>I can see differences in the README.md files with the command git diff.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uQFpO_A0UY4_P-JqpT9ByA.png" /></figure><p>If I can send it to my git repository, all modifications will go in one commit. How do I select each line of the file to send in a different commit?</p><p>Ok don’t problem, has a command gti add -p. With this option, I can select what hunk I want to send in my commit.</p><pre>       -p, --patch<br>           Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance<br>           to review the difference before adding modified contents to the index.<br><br>           This effectively runs add --interactive, but bypasses the initial command menu and directly jumps to the patch subcommand. See<br>           “Interactive mode” for details.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cfPieDQmp8kMBOQfyfDiQQ.png" /></figure><pre># add change use patch<br>❯ git add -p<br>diff --git a/README.md b/README.md<br>index ff31f6e..0d1b301 100644<br>--- a/README.md<br>+++ b/README.md<br>@@ -1,9 +1,12 @@<br> # Project GIT<br><br> This project is for tutorial<br>+This for commit A<br> of GIT and some commands.<br>+This for commit B<br><br> I need add author and<br> more description or history.<br>+This for commit A<br><br> 11/27/2023<br># a list option appear, if i can see what do each letter, only press Enter or &#39;?&#39;<br># I select &#39;s&#39; of split for select what line I want add in my &#39;stage area&#39;<br>(1/1) Stage this hunk [y,n,q,a,d,s,e,?]? s<br># Now only press &#39;y&#39; if wish add in my commmit or &#39;n&#39; opposite case. But if I want stop press &#39;q&#39;<br>Split into 3 hunks.<br>@@ -1,4 +1,5 @@<br> # Project GIT<br><br> This project is for tutorial<br>+This for commit A<br> of GIT and some commands.<br>(1/3) Stage this hunk [y,n,q,a,d,j,J,g,/,e,?]? y<br>@@ -4,4 +5,5 @@<br> of GIT and some commands.<br>+This for commit B<br><br> I need add author and<br> more description or history.<br>(2/3) Stage this hunk [y,n,q,a,d,K,j,J,g,/,e,?]? n<br>@@ -5,5 +7,6 @@<br><br> I need add author and<br> more description or history.<br>+This for commit A<br><br> 11/27/2023<br>(3/3) Stage this hunk [y,n,q,a,d,K,g,/,e,?]? y<br><br># see status, the file README.md has two commits<br> git status<br>On branch master<br>Changes to be committed:<br>  (use &quot;git restore --staged &lt;file&gt;...&quot; to unstage)<br>        modified:   README.md<br><br>Changes not staged for commit:<br>  (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)<br>  (use &quot;git restore &lt;file&gt;...&quot; to discard changes in working directory)<br>        modified:   README.md</pre><p>With command git diff — -stage can see only the change that i was selected</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sbzkQUo2HhDWItspmn2PCQ.png" /></figure><pre># add last changes<br>git commit -m &#39;commit A - add description&#39;<br>[master ce86c07] commit A - add description<br> 1 file changed, 2 insertions(+)<br><br># see status of workdirectory, and now only has one commit<br>❯ git status<br>On branch master<br>Changes not staged for commit:<br>  (use &quot;git add &lt;file&gt;...&quot; to update what will be committed)<br>  (use &quot;git restore &lt;file&gt;...&quot; to discard changes in working directory)<br>        modified:   README.md<br><br>no changes added to commit (use &quot;git add&quot; and/or &quot;git commit -a&quot;)</pre><p>See diff in my work directory</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pSinVCD1Bg8hxl6xCULC9Q.png" /></figure><pre># add in my stage area<br>❯ git add .<br><br># commit to git repository<br>❯ git commit -m &#39;commit B - add more description&#39;<br>[master 7291a36] commit B - add more description<br> 1 file changed, 1 insertion(+)<br><br># see log of this handson<br>❯ git log --oneline<br>7291a36 (HEAD -&gt; master) commit B - add more description<br>ce86c07 commit A - add description<br>1f0ec5f start content README file<br>2bfa94f add README file<br>40b2e2a add index files<br>bd14411 add javascript</pre><h3>Conclusion</h3><p>Git is a good tool for developers, and learning how to use it is a necessity.</p><p>Thanks for reading me !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=721376eeb624" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GIT | Exploring]]></title>
            <link>https://medium.com/@alejandrofuentesar/git-exploring-f5d6f7833e4a?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f5d6f7833e4a</guid>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Sun, 26 Nov 2023 11:12:29 GMT</pubDate>
            <atom:updated>2023-11-26T11:21:33.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/674/1*wxZejehrLCH3YswTOkqtaw.png" /></figure><h3>Exploring the world of Git</h3><h4>Types of Objects</h4><p>In Git, there are several types of objects that are fundamental to its functioning. These objects are used to store different kinds of data within a Git repository.</p><ul><li><strong>Blob</strong>: is a file. Blobs store the content of the files, but they do not contain any metadata about the file.</li><li><strong>Tree</strong>: is a path or folder. A tree object contains references to blobs (<em>files</em>) and other trees (<em>subdirectories</em>). It essentially represents a snapshot of the project’s directory structure.</li><li><strong>Commit</strong>: is a snapshot. A commit object contains a reference to a tree object (<em>representing the directory structure</em>), metadata such as the author and commit message, and a reference to the previous commit, forming a linked history of changes.</li><li><strong>Tag</strong>: is a mark for a special commit. This is often done to mark important points in the project’s history, such as a release or a stable version. Tags are immutable references to a specific commit.</li></ul><h4>Hash of Objects</h4><p>In Git, each object (<em>blob, tree, commit, and tag</em>) is identified and named by a unique hash, which is a long string of characters generated by applying a hash function (<em>SHA-1</em>) to the object’s content. This hash is commonly a 40-character hexadecimal number.</p><pre># Examples of hash:<br><br>SHA1 hash: b0cecd5efa3a0bc91025... (until 40 characters)<br>short hash: b0cecd5 (7 characters) </pre><h3>Hands-On</h3><p>Create our work directory</p><pre># create and got to workdirectory<br>study/devops/git<br>❯ mkdir my-local-repo<br><br>study/devops/git<br>❯ cd my-local-repo<br><br># see the git version<br>devops/git/my-local-repo<br>❯ git --version<br>git version 2.25.1</pre><p>Verify the structure of the files after init git in our work directory</p><pre># see that is empty <br>devops/git/my-local-repo<br>❯ ll<br>total 0<br><br># started git in my directory<br>devops/git/my-local-repo<br>❯ git init<br>Initialized empty Git repository in /home/alefu/study/devops/git/my-local-repo/.git/<br><br><br>my-local-repo on  master<br>❯ ll<br>total 0<br><br># see hidden files in my directory, and can see how git was created &#39;.git&#39; directory<br>my-local-repo on  master<br>❯ ls -a<br>.  ..  .git</pre><p>Change the name of the branch ‘master’ to ‘main’ for good practice.</p><pre># Try change the name of my branch &#39;master&#39; to main<br>❯ git branch -m main<br>error: refname refs/heads/master not found<br>fatal: Branch rename failed</pre><p>But I have an error when I try to change the name. For this situation, I try to edit some properties of my working directory. I go to see</p><pre># see the &#39;.git&#39; directory<br>❯ ls -a<br>.  ..  .git<br><br># See inner directory &#39;.git&#39;<br>❯ ll .git/<br>total 32K<br>-rw-r--r-- 1 alefu alefu   23 Nov 21 19:49 HEAD<br>drwxr-xr-x 2 alefu alefu 4.0K Nov 21 19:49 branches<br>-rw-r--r-- 1 alefu alefu   92 Nov 21 19:49 config<br>-rw-r--r-- 1 alefu alefu   73 Nov 21 19:49 description<br>drwxr-xr-x 2 alefu alefu 4.0K Nov 21 19:49 hooks<br>drwxr-xr-x 2 alefu alefu 4.0K Nov 21 19:49 info<br>drwxr-xr-x 4 alefu alefu 4.0K Nov 21 19:49 objects<br>drwxr-xr-x 4 alefu alefu 4.0K Nov 21 19:49 refs<br><br># see the file &#39;HEAD&#39;<br>❯ cat .git/HEAD<br>ref: refs/heads/master<br><br># edito usin some anyone editor, change the &#39;master&#39; for &#39;main&#39;<br>❯ micro .git/HEAD<br><br>❯ cat .git/HEAD<br>ref: refs/heads/main<br><br># with &#39;git status&#39; can see that now the branc name is &#39;main&#39;<br>❯ git status<br>On branch main<br><br>No commits yet<br><br>nothing to commit (create/copy files and use &quot;git add&quot; to track)</pre><p>Add a new file</p><pre><br># create a new file<br>❯ echo &#39;GIT | Exploring Git&#39; &gt; devops.txt<br><br>❯ ls\<br>∙<br>devops.txt<br><br># see inner &#39;.git/objects&#39; directory your status<br>❯ ls .git/objects<br>info  pack<br><br># check the status of my work directory<br>❯ git status<br>On branch main<br><br>No commits yet<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        devops.txt<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)<br><br># add this file in my stage<br>❯ git add devops.txt<br><br># check the status of my work directory<br>❯ git status<br>On branch main<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   devops.txt<br><br># add configuration ussing &#39;--local&#39; paranm, for set user a email localy and not global<br>❯ git config --local user.name &#39;ale fuentes&#39;<br>❯ git config --local user.email &#39;ale.fuentes@ale.com&#39;<br><br># I&#39;ll see how it turns out my config git<br>❯ git config --list<br>core.editor=/usr/bin/editor<br>pager.show=delta<br>core.pager=delta<br>delta.side-by-side=true<br>core.repositoryformatversion=0<br>core.filemode=true<br>core.bare=false<br>core.logallrefupdates=true<br>user.name=ale fuentes<br>user.email=ale.fuentes@ale.com<br><br># I see inner &#39;.git/objects&#39; and git was create a new folder<br>❯ ls .git/objects<br>f7  info  pack<br><br># commit my change, the new file in the work directory<br>❯ git commit -m &#39;feat - my firts commit&#39;<br>[main (root-commit) c71bebe] feat - my firts commit<br> 1 file changed, 1 insertion(+)<br> create mode 100644 devops.txt<br><br># I see inner &#39;.git/objects&#39; wow, git was create a several new folders<br>❯ ls .git/objects<br>49  c7  f7  info  pack<br><br># i can see log of my ativities with more details<br>❯ git log<br>commit c71bebea43643370ef2ca9450c7e76d25ceef489 (HEAD -&gt; main)<br>Author: ale fuentes &lt;ale.fuentes@ale.com&gt;<br>Date:   Tue Nov 21 20:32:39 2023 -0300<br><br>    feat - my firts commit<br><br># or can see logs in simple details<br>❯ git log --oneline<br>c71bebe (HEAD -&gt; main) feat - my firts commit<br></pre><p>Exploring the objects in git</p><pre># see all files in my workdirectory<br>❯ ls<br>devops.txt<br><br># see hide files<br>❯ ls -a<br>.  ..  .git  devops.txt<br><br># see all objects inner &#39;.git/objects&#39; directory<br>❯ ls .git/objects<br>49  c7  f7  info  pack<br><br># see content of &#39;.git/objects/c7&#39; directory (remember the name of folder &#39;c7&#39;)<br>❯ ls .git/objects/c7<br>1bebea43643370ef2ca9450c7e76d25ceef489<br><br># try see type of file ussing command &#39;cat-file&#39;<br>❯ git cat-file -t 1bebea43643370ef2ca9450c7e76d25ceef489<br>fatal: Not a valid object name 1bebea43643370ef2ca9450c7e76d25ceef489<br><br># I have a erro, because I forget to add to the beginner the name of folder &#39;c7&#39;<br>my-local-repo on  main<br>❯ git cat-file -t c71bebea43643370ef2ca9450c7e76d25ceef489<br>commit<br><br># now, I will see the content of this object (remeber add the name folder &#39;c7&#39; beginner<br>❯ git cat-file -p c71bebea43643370ef2ca9450c7e76d25ceef489<br>tree 49b11b0ee1cf7dcb1f69cda79aa70ed5c2b498a3<br>author ale fuentes &lt;ale.fuentes@ale.com&gt; 1700609559 -0300<br>committer ale fuentes &lt;ale.fuentes@ale.com&gt; 1700609559 -0300<br><br>feat - my firts commit<br><br># now I see the content of tree that get of previous result<br>❯ git cat-file -p 49b11b0ee1cf7dcb1f69cda79aa70ed5c2b498a3<br>100644 blob f7590a164628abd6d9f41bae6d8dbf64415d9905    devops.txt<br></pre><p>I do more example</p><pre># add a new file<br>❯ echo &#39;AWS, GCP, Azure, OCI&#39; &gt; providers.txt<br><br># see all files in my workdirectory<br>❯ ls<br>devops.txt  providers.txt<br><br># see content of &#39;providers.txt&#39; file<br>❯ cat providers.txt<br>AWS, GCP, Azure, OCI<br><br># see that status of my workdirectory has a untracked file<br>❯ git status<br>On branch main<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        providers.txt<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)<br><br># add this change in my &#39;stage&#39; area<br>❯ git add .<br><br># see status, the change is ready fo move to &#39;git repository&#39;<br>❯ git status<br>On branch main<br>Changes to be committed:<br>  (use &quot;git restore --staged &lt;file&gt;...&quot; to unstage)<br>        new file:   providers.txt<br><br># see my log of activities<br>❯ git log<br>commit c71bebea43643370ef2ca9450c7e76d25ceef489 (HEAD -&gt; main)<br>Author: ale fuentes &lt;ale.fuentes@ale.com&gt;<br>Date:   Tue Nov 21 20:32:39 2023 -0300<br><br>    feat - my firts commit<br><br># add this change in my &#39;git repository&#39;<br>❯ git commit -m &#39;feat - second commit&#39;<br>[main 1ee5847] feat - second commit<br> 1 file changed, 1 insertion(+)<br> create mode 100644 providers.txt<br><br># now the status tells me that no have new changes<br>❯ git status<br>On branch main<br>nothing to commit, working tree clean<br><br># see the log, where I can see all changes in my workdirectory<br>❯ git log<br>commit 1ee584769c389fc684317f77146041fcf9ee96d9 (HEAD -&gt; main)<br>Author: ale &lt;ale.fuentes@ale.com&gt;<br>Date:   Wed Nov 22 07:13:24 2023 -0300<br><br>    feat - second commit<br><br>commit c71bebea43643370ef2ca9450c7e76d25ceef489<br>Author: ale fuentes &lt;ale.fuentes@ale.com&gt;<br>Date:   Tue Nov 21 20:32:39 2023 -0300<br><br>    feat - my firts commit<br><br># see a resume log usse &#39;--oneline&#39; param<br>❯ git log --oneline<br>1ee5847 (HEAD -&gt; main) feat - second commit<br>c71bebe feat - my firts commit<br></pre><h3>BRANCH</h3><p>Branch refers to a parallel line of development. Developers create branches to work on features, bug fixes, or other changes without affecting the main or “master” branch. Once the changes in a branch are complete and tested, they can be merged back into the main branch.</p><ul><li>One repository can have one or more branches.</li><li>This allows the many developers can work simultaneously.</li><li>All accepted changes in branches will merge into a main branch.</li></ul><pre># see a list of branch in my workdirectory<br>❯ git branch<br>* main<br><br># create a new branch called &#39;feature1&#39;<br>❯ git branch feature1<br><br># see a list of branch<br>❯ git branch<br>  feature1<br>* main<br><br># with &#39;checkout&#39; commmand change for &#39;feature1&#39; branch<br>❯ git checkout feature1<br>Switched to branch &#39;feature1&#39;<br><br># see that branch active is &#39;feature1&#39; (*)<br>❯ git branch<br>* feature1<br>  main<br><br># add a new file<br>❯ echo &#39;New feature&#39; &gt; new-feature-1.txt<br><br># see to status of my workdirectory<br>❯ git status<br>On branch feature1<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        new-feature-1.txt<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)<br><br># add this file for my &#39;stage&#39; area of my &#39;feature1&#39; branch<br>❯ git add new-feature-1.txt<br><br># see status of my workdirectory<br>❯ git status<br>On branch feature1<br>Changes to be committed:<br>  (use &quot;git restore --staged &lt;file&gt;...&quot; to unstage)<br>        new file:   new-feature-1.txt<br><br><br># now, I add this changes in my git repository<br>❯ git commit -m &#39;feat - my first feature&#39;<br>[feature1 97eaa1f] feat - my first feature<br> 1 file changed, 1 insertion(+)<br> create mode 100644 new-feature-1.txt<br><br># see all files of my wordirectory of my &#39;feature1&#39; directory<br>❯ ls<br>devops.txt  new-feature-1.txt  providers.txt<br><br># change for &#39;main&#39; branch <br>❯ git checkout main<br>Switched to branch &#39;main&#39;<br><br># see all files of my workdirectory, I noticed that one file of &#39;feature1&#39; branch don&#39;t listing in &#39;main&#39; branch<br>❯ ls<br>devops.txt  providers.txt<br><br># add a new file in my &#39;main&#39; branch<br>❯ echo &#39;General Data Protection Regulation&#39; &gt; gdpr.txt<br><br># see status of my workdirectory<br>❯ git status<br>On branch main<br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        gdpr.txt<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)<br><br># add the new file in my &#39;state&#39; area fo &#39;main&#39; branch<br>❯ git add gdpr.txt<br><br># see status of my workdirectory<br>❯ git status<br>On branch main<br>Changes to be committed:<br>  (use &quot;git restore --staged &lt;file&gt;...&quot; to unstage)<br>        new file:   gdpr.txt<br><br><br># add this change to git repository<br>❯ git commit -m &#39;feat - add gdrp EU privacy law&#39;<br>[main 0342a10] feat - add gdrp EU privacy law<br> 1 file changed, 1 insertion(+)<br> create mode 100644 gdpr.txt<br><br># see all files in my workdirectory of &#39;main&#39; branch<br>❯ ls<br>devops.txt  gdpr.txt  providers.txt</pre><h3>MERGE</h3><p>It’s an activity where to combine changes from different branches into a single branch.</p><p>I has two branch, the principal branch main and de auxiliary branch is feature1. After finishing my activity in the branchfeature1 , I will combine all changes in my principal branch.</p><pre># see log<br>❯ git log --oneline<br>0342a10 (HEAD -&gt; main) feat - add gdrp EU privacy law<br>1ee5847 feat - second commit<br>c71bebe feat - my firts commit<br><br># see a list of branchs, when the branch &#39;main&#39; is selected (*)<br>❯ git branch<br>  feature1<br>* main<br><br># now I bring the changes from the &#39;feature1&#39; into branch &#39;main&#39;<br>❯ git merge feature1<br><br># NOTE: in this time, one editor appoeart for add some description if we want.<br># it depend of editor, you edit o save. e.x: with Vim, you use &#39;i&#39; for editn<br># &#39;ESC&#39; for finish, and &#39;:wq&#39; for write the file a quit<br><br>Merge made by the &#39;recursive&#39; strategy.<br> new-feature-1.txt | 1 +<br> 1 file changed, 1 insertion(+)<br> create mode 100644 new-feature-1.txt<br><br># list all files of my workdirectory, can see a news files from &#39;feature1&#39; branch in &#39;main&#39; brangh.<br>❯ ls<br>devops.txt  gdpr.txt  new-feature-1.txt  providers.txt<br><br># delete the branch after merge with main branch<br>❯ git branch -d feature1<br>Deleted branch feature1 (was 97eaa1f).<br><br># see the list of branch<br>❯ git branch<br>* main</pre><h3>Conclusion</h3><p>In a nutshell, Git is a great tool for version control systems, swooping in to save to day of work for developers everywhere.</p><p>They do work how magic by breaking down the project into nifty objects.</p><p><strong>blobs</strong> for file content, <strong>trees</strong> for the project’s layout, <strong>commits</strong> for snapshots of the coding journey, and <strong>tags</strong> for those epic release points.</p><p>But wait, there’s more! Each of these objects gets a unique identity, a hash that ensures no coding mishap goes unnoticed.</p><p>In the world of software development, Git isn’t just a tool; it’s the caped crusader keeping your codebase safe and sound.</p><p>So, embrace Git, and do a good history.</p><p>Thanks a lot for reading me.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f5d6f7833e4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GIT | Some tips for good practice]]></title>
            <link>https://medium.com/@alejandrofuentesar/git-some-tips-for-good-practice-a4eeac817c95?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a4eeac817c95</guid>
            <category><![CDATA[git]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Sat, 25 Nov 2023 15:19:06 GMT</pubDate>
            <atom:updated>2023-11-27T23:19:28.904Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/835/1*nbx6g2OEkHfpJfg18bpCBw.png" /></figure><p>Git histories are very important for knowing how our project has grown and is the responsibility of each user the make this history clean, ordered, on so on.</p><p>In this post, I doing some topics about how I work in some situations.</p><h3>How the git work</h3><p>Git has three main areas or “zones” that are important for managing changes: the working directory, the staging area (also known as the index), and the repository.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/379/1*JHPaAcAHgq6fBdf9Xp4IwA.png" /></figure><p>When I create a new file, this file only exists in the <em>working directory</em>, if I want to move to the <em>staging area</em>, I use the command add. After the file is in the <em>staging area</em> two actions that I can do send to the <em>git repository</em>, or revert to the <em>working directory</em>.</p><pre># Make Changes: Edit files in your working directory.<br><br># Check Status:<br>git status<br><br># Stage Changes:<br>git add &lt;filename&gt;<br><br># Check Staged Changes:<br>git diff --staged<br><br># Commit Changes:<br>git commit -m &quot;Your commit message&quot;<br><br># View Commit History:<br>git log<br><br># To unstage changes:<br>git reset &lt;filename&gt;<br><br># To discard changes in the working directory:<br>git checkout -- &lt;filename&gt;</pre><blockquote>Always correct things the moment I notice the mistake</blockquote><p>This topic is when for several reasons, I write a bad message in the commit and want to change for one correct message.</p><p>Some examples of bad messages: <em>fix, hot fix, adding, on so on</em>.</p><p>Ok, I can write any message in my local repository, but when I push for the main repository, is a good idea to change for a correct message.</p><blockquote>do not <strong>change commits</strong> that you’ve already shared with others. You’re changing history and it will cause trouble for others.</blockquote><p><strong>Now, is an example of how to correct a message in one commit</strong>:</p><ul><li>Create a local repository</li></ul><pre># create my local repository and init git<br>❯ mkdir test-message-1<br>❯ cd test-message-1<br>❯ git init<br>Initialized empty Git repository in /home/alefu/study/devops/git/topic-repo/test-message-1/.git/<br><br># now, for testing add some files<br>❯ touch file001.txt<br>❯ touch file002.cnf<br><br># view my status, where two files has &#39;untracked&#39; and wait for send to &#39;stage&#39; area<br>❯ git status<br>On branch master<br><br>No commits yet<br><br>Untracked files:<br>  (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)<br>        file001.txt<br>        file002.cnf<br><br>nothing added to commit but untracked files present (use &quot;git add&quot; to track)</pre><ul><li>Add the changes and commit with the wrong message</li></ul><pre># add all changes to &#39;stage&#39; area<br>❯ git add .<br>❯ git status<br>On branch master<br><br>No commits yet<br><br>Changes to be committed:<br>  (use &quot;git rm --cached &lt;file&gt;...&quot; to unstage)<br>        new file:   file001.txt<br>        new file:   file002.cnf<br><br># set commit with explanation message, but with wrong message<br>❯ git commit -m &quot;One wrong message&quot;<br>[master (root-commit) a86b520] One wrong message<br> 2 files changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 file001.txt<br> create mode 100644 file002.cnf<br><br>❯ git log --oneline<br>a86b520 (HEAD -&gt; master) One wrong message</pre><ul><li>before sending it to the main repository, I to fix it for the correct message using the — amendparam</li></ul><pre># correct message using the &#39;--amend&#39; param<br>❯ git commit -m &quot;Add two files&quot; --amend<br>[master 0954da1] Add two files<br> Date: Sat Nov 25 10:12:43 2023 -0300<br> 2 files changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 file001.txt<br> create mode 100644 file002.cnf<br><br># see how to message is<br>❯ git log --oneline<br>0954da1 (HEAD -&gt; master) Add two files<br></pre><p>Ok, this easy example, but gonna another situation. I had focused on doing a task, but I did it in different steps, but… my error is that in each step I used the same message 😕</p><ul><li>Do several activities and set the same message:</li></ul><pre># add my first activity<br>❯ touch db.txt<br>❯ git add .<br>❯ git commit -m &#39;adding&#39;<br>[master 45942ca] adding<br> 1 file changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 db.txt<br><br># add my second activity<br>❯ touch db-fix.txt<br>❯ git add .<br>❯ git commit -m &#39;adding&#39;<br>[master 3ecde98] adding<br> 1 file changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 db-fix.txt<br><br># add my third activity<br>❯ touch db-fix-2.txt<br>❯ git add .<br>❯ git commit -m &#39;adding&#39;<br>[master 5e9afff] adding<br> 1 file changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 db-fix-2.txt<br><br># see my log<br>❯ git log --oneline<br>5e9afff (HEAD -&gt; master) adding<br>3ecde98 adding<br>45942ca adding<br>0954da1 Add two files<br></pre><p>Ok, now I try to fix these commits, thinking.. thinking… 🧠</p><h4>Reset</h4><p>One way is navigating for the graph os git commit, remembering that the last commit is called HEAD . I can return for previous commits indicate with a number the jump from the last commit, for that, I can use the command reset .</p><pre>GIT-RESET(1)                                                     Git Manual                                                    GIT-RESET(1)<br><br>NAME<br>       git-reset - Reset current HEAD to the specified state<br><br>SYNOPSIS<br>       git reset [-q] [&lt;tree-ish&gt;] [--] &lt;pathspec&gt;...<br>       git reset [-q] [--pathspec-from-file=&lt;file&gt; [--pathspec-file-nul]] [&lt;tree-ish&gt;]<br>       git reset (--patch | -p) [&lt;tree-ish&gt;] [--] [&lt;pathspec&gt;...]<br>       git reset [--soft | --mixed [-N] | --hard | --merge | --keep] [-q] [&lt;commit&gt;]<br><br>DESCRIPTION<br>       In the first three forms, copy entries from &lt;tree-ish&gt; to the index. In the last form, set the current branch head (HEAD) to<br>       &lt;commit&gt;, optionally modifying index and working tree to match. The &lt;tree-ish&gt;/&lt;commit&gt; defaults to HEAD in all forms.</pre><p>Reset has different modes: hardand soft. I will use the soft because I only can reset all commits and not all the files’ inner commits.:</p><pre> git reset [&lt;mode&gt;] [&lt;commit&gt;]<br>           This form resets the current branch head to &lt;commit&gt; and possibly updates the index (resetting it to the tree of &lt;commit&gt;) and<br>           the working tree depending on &lt;mode&gt;. If &lt;mode&gt; is omitted, defaults to --mixed. The &lt;mode&gt; must be one of the following:<br><br>           --soft<br>               Does not touch the index file or the working tree at all (but resets the head to &lt;commit&gt;, just like all modes do). This<br>               leaves all your changed files &quot;Changes to be committed&quot;, as git status would put it.<br><br>           --hard<br>               Resets the index and working tree. Any changes to tracked files in the working tree since &lt;commit&gt; are discarded.</pre><h4>Example reset — soft</h4><ul><li>First, a return to commit where started the task</li></ul><pre># See current log<br>❯ git log --oneline<br>5e9afff (HEAD -&gt; master) adding<br>3ecde98 adding<br>45942ca adding<br>0954da1 Add two files<br><br># I jump to number the row of the commit<br># 1 - 5e9afff (HEAD -&gt; master) adding<br># 2 - 3ecde98 adding<br># 3 - 45942ca adding  &lt;- is here where start the task<br># 4 - 0954da1 Add two files<br>❯ git reset --soft HEAD~3<br><br># see the log now<br>❯ git log --oneline<br>0954da1 (HEAD -&gt; master) Add two files<br><br># Now my status is like this<br>❯ git status<br>On branch master<br>Changes to be committed:<br>  (use &quot;git restore --staged &lt;file&gt;...&quot; to unstage)<br>        new file:   db-fix-2.txt<br>        new file:   db-fix.txt<br>        new file:   db.txt</pre><ul><li>Now, set a message more cool</li></ul><pre><br>❯ git commit -m &#39;Adding DB files&#39;<br>[master 6272d9f] Adding DB files<br> 3 files changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 db-fix-2.txt<br> create mode 100644 db-fix.txt<br> create mode 100644 db.txt<br><br># see my log<br>❯ git log --oneline<br>6272d9f (HEAD -&gt; master) Adding DB files<br>0954da1 Add two files</pre><h4>Rebase</h4><p>I think that this way is more steps but more to used for the develops.</p><pre>GIT-REBASE(1)                                                    Git Manual                                                   GIT-REBASE(1)<br><br>NAME<br>       git-rebase - Reapply commits on top of another base tip<br><br>SYNOPSIS<br>       git rebase [-i | --interactive] [&lt;options&gt;] [--exec &lt;cmd&gt;]<br>               [--onto &lt;newbase&gt; | --keep-base] [&lt;upstream&gt; [&lt;branch&gt;]]<br>       git rebase [-i | --interactive] [&lt;options&gt;] [--exec &lt;cmd&gt;] [--onto &lt;newbase&gt;]<br>               --root [&lt;branch&gt;]<br>       git rebase (--continue | --skip | --abort | --quit | --edit-todo | --show-current-patch)<br><br>DESCRIPTION<br>       If &lt;branch&gt; is specified, git rebase will perform an automatic git switch &lt;branch&gt; before doing anything else. Otherwise it remains<br>       on the current branch.</pre><p>For I can do more manipulation in my commit, I can use the options — interactiveof rebase command, this way, I can select what commit can join.</p><pre>       -i, --interactive<br>           Make a list of the commits which are about to be rebased. Let the user edit that list before rebasing. This mode can also be<br>           used to split commits (see SPLITTING COMMITS below).<br><br>           The commit list format can be changed by setting the configuration option rebase.instructionFormat. A customized instruction<br>           format will automatically have the long commit hash prepended to the format.<br><br>           See also INCOMPATIBLE OPTIONS below.</pre><p>Now, I do use hard in reset git’s command for erasing files and re-create the same situation.</p><pre># current log<br>❯ git log --oneline<br>6272d9f (HEAD -&gt; master) Adding DB files<br>0954da1 Add two files<br><br># reset to before &#39;commit&#39; but with &#39;reset --hard&#39; erasing all files of last commit <br>❯ git reset --hard HEAD~1<br>HEAD is now at 0954da1 Add two files<br><br>❯ git log --oneline<br>0954da1 (HEAD -&gt; master) Add two files<br><br># the files added in the last reseted&#39; &#39;commit&#39; are deleted<br>❯ ll<br>total 0<br>-rw-r--r-- 1 alefu alefu 0 Nov 25 10:06 file001.txt<br>-rw-r--r-- 1 alefu alefu 0 Nov 25 10:06 file002.cnf</pre><ul><li>Add files to prepare the test</li></ul><pre># add files<br>❯ touch db.txt<br>git add .<br>git commit -m &#39;adding&#39;<br><br>[master e2047dc] adding<br> 1 file changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 db.txt<br><br>❯ touch db-fix.txt<br>git add .<br>git commit -m &#39;adding&#39;<br><br>[master 47ca531] adding<br> 1 file changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 db-fix.txt<br><br>❯ touch db-fix-2.txt<br>git add .<br>git commit -m &#39;adding&#39;<br>[master 91a148b] adding<br> 1 file changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 db-fix-2.txt<br><br>test-message-1 on  master<br><br># see log<br>❯ git log --oneline<br>91a148b (HEAD -&gt; master) adding<br>47ca531 adding<br>e2047dc adding<br>0954da1 Add two files<br><br># see files in directory<br>❯ ll<br>total 0<br>-rw-r--r-- 1 alefu alefu 0 Nov 25 11:29 db-fix-2.txt<br>-rw-r--r-- 1 alefu alefu 0 Nov 25 11:29 db-fix.txt<br>-rw-r--r-- 1 alefu alefu 0 Nov 25 11:29 db.txt<br>-rw-r--r-- 1 alefu alefu 0 Nov 25 10:06 file001.txt<br>-rw-r--r-- 1 alefu alefu 0 Nov 25 10:06 file002.cnf</pre><ul><li>Selecting my commits to join it I use the command squash (<em>meld into the previous commit</em>), change in the two lastest commits the pick command for squash command in the new window</li></ul><pre>pick e2047dc adding<br>squash 47ca531 adding<br>squash 91a148b adding<br><br># Rebase 0954da1..91a148b onto 0954da1 (3 commands)<br>#<br># Commands:<br># p, pick &lt;commit&gt; = use commit<br># r, reword &lt;commit&gt; = use commit, but edit the commit message<br># e, edit &lt;commit&gt; = use commit, but stop for amending<br># s, squash &lt;commit&gt; = use commit, but meld into previous commit<br># f, fixup &lt;commit&gt; = like &quot;squash&quot;, but discard this commit&#39;s log message<br># x, exec &lt;command&gt; = run command (the rest of the line) using shell<br># b, break = stop here (continue rebase later with &#39;git rebase --continue&#39;)<br># d, drop &lt;commit&gt; = remove commit<br># l, label &lt;label&gt; = label current HEAD with a name<br># t, reset &lt;label&gt; = reset HEAD to a label<br># m, merge [-C &lt;commit&gt; | -c &lt;commit&gt;] &lt;label&gt; [# &lt;oneline&gt;]<br># .       create a merge commit using the original merge commit&#39;s<br># .       message (or the oneline, if no original merge commit was<br># .       specified). Use -c &lt;commit&gt; to reword the commit message.</pre><ul><li>The next step is a new window where I need to write the message. I clear the last message and write a new message</li></ul><pre>Adding DB files<br><br># Please enter the commit message for your changes. Lines starting<br># with &#39;#&#39; will be ignored, and an empty message aborts the commit.<br>#<br># Date:      Sat Nov 25 11:29:26 2023 -0300<br>#<br># interactive rebase in progress; onto 0954da1<br># Last commands done (3 commands done):<br>#    squash 47ca531 adding<br>#    squash 91a148b adding<br># No commands remaining.<br># You are currently rebasing branch &#39;master&#39; on &#39;0954da1&#39;.<br>#<br># Changes to be committed:<br># new file:   db-fix-2.txt<br># new file:   db-fix.txt<br># new file:   db.txt<br>#</pre><ul><li>after to save, return the console, and see my log</li></ul><pre># finished process of rebase<br>❯ git rebase -i HEAD~3<br>[detached HEAD 1056acd] Adding DB files<br> Date: Sat Nov 25 11:29:26 2023 -0300<br> 3 files changed, 0 insertions(+), 0 deletions(-)<br> create mode 100644 db-fix-2.txt<br> create mode 100644 db-fix.txt<br> create mode 100644 db.txt<br>Successfully rebased and updated refs/heads/master.<br><br># see my log<br>❯ git log --oneline<br>1056acd (HEAD -&gt; master) Adding DB files<br>0954da1 Add two files</pre><h3>Conclusion</h3><p>Git is a good tool for developers, have many way to use it to improve our code repositories I think that any programmer need to know.</p><p>Thanks for reading me !!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a4eeac817c95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DEVOPS | Conceptos soft-skills y hard-skills]]></title>
            <link>https://medium.com/@alejandrofuentesar/devops-conceptos-soft-skills-y-hard-skills-1fd120cdea40?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/1fd120cdea40</guid>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Sun, 19 Nov 2023 23:26:37 GMT</pubDate>
            <atom:updated>2023-11-22T10:05:34.394Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>“…DevOps es la unión de personas, procesos y productos para permitir la entrega continua de valores a nuestros usuários finales...” — Donovan Brown en <a href="https://www.donovanbrown.com/post/what-is-devops">What is DevOps?</a></blockquote><h3>Iniciando con una breve definición</h3><h4>SDLC</h4><p>SDLC (<em>Software Development Life Cycle </em>o en su traducción <em>Ciclo de Vida del Desarrollo de Software</em>) es un framework para el desarrollo de software de una forma práctica, sistemática y con costo-beneficio.</p><p>Este consiste en un plano que describe como el software será desarrollado, administrado y mejorado.</p><p>Cada fase tiene su proceso y entrega que alimenta a la próxima fase.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/535/1*p85sIWvZ0vQAadGmCtHoBw.png" /></figure><p><strong>Planeamiento</strong>: en esta etapa se define todas las informaciones del producto/software, así como funcionalidades, especificaciones, expectativas y todo lo relacionado a requisitos necesario.</p><p><em>De ahí va para el siguiente paso…</em></p><p><strong>Diseño</strong>: Es el momento de especificar el <em>design</em> con base en los requisitos para determinar las prioridades, las herramientas, proveedores de cloud, bancos de datos, lenguaje de programación, etc.</p><p><em>De ahí va para el siguiente paso…</em></p><p><strong>Codificación</strong>: Es la etapa más larga, el equipo de desarrolladores (Dev) comienzan a desarrollar el sistema escribiendo códigos con tareas divididas en unidades o módulos y atribuidas a varios desarrolladores.</p><p><em>De ahí va para el siguiente paso…</em></p><p><strong>Testar</strong>: aquí es donde el equipo de QA (<em>Quality Assurance</em>) son los responsables en testar y verificar que la calidad del software (en lo que respecta reglas de negocio, funcionalidad del sistema, etc.) y detectar cualquier Bugs/problemas.</p><p><em>De ahí va para el siguiente paso…</em></p><p><strong>Implementación</strong>: Después del equipo de QA garantir que el software funciona como se espera, o sea sin ningún problema identificado, se ira implantar el software en ambientes productivos, donde los usuarios harán uso del servicio proporcionado por el sistema.</p><p><em>De ahí va para el siguiente paso…</em></p><p><strong>Mantenimiento</strong>: Es la fase donde se debe dar garantías que el sistema funcione continuamente de acuerdo con los requisitos aceptados en la primera fase. Actualizaciones, correcciones de Bugs son algunos ejemplos de lo que pueden surgir en esta etapa, siendo así, el siguiente paso será:</p><p><em>Retorno a la primera fase…</em></p><p>Donde se repetirá los pasos de análisis, desarrollo, teste, implementar en ambiente productivo, etc.</p><h4>Similitud com DevOps</h4><p>SDLC con sus pasos es parecido a filosofia DevOps</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uOCftiGMZBFn7jW92ZGarA.png" /></figure><h3>Modelos de desarrollo de software</h3><h4>Waterfall Vs Agile</h4><p><strong>Waterfall</strong>, divide las actividades del proyecto en una orden secuencial, y con esto, el equipo de desarrolladores del proyecto sólo pasará a la próxima etapa si la etapa anterior fuera concluida <strong>con suceso</strong>.</p><blockquote>las etapas subsecuentes dependen de las entregas anteriores</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*de_bAQNduBmqD62npoXHNQ.png" /></figure><p><strong>Agile</strong>, divide el proyecto en varias etapas, proporcionando una <em>iteración continua</em> entre las tareas de desenvolvimiento y testes.</p><blockquote>Permite mas comunicación o colaboración entre los diferentes equipos de trabajo.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/706/0*Yzbxi0Q8lupod8zJ.png" /></figure><h4>¿Cuál es mejor?</h4><p>A pesar de que son dos formas de actuar ante un proyecto, no existe la mejor técnica y si la mejor forma que se adapte al tipo de proyecto.</p><p>Waterfall se encaja bien en proyectos pequeños, mientras que Agile, en proyectos más complejos y quizás donde la necesidad de actualizar a mudanzas deba tener una respuesta rápida.</p><h3>DevOps</h3><h4>¿DevOps es una filosofia o una tecnologia?</h4><blockquote>¿Dónde se compra?</blockquote><blockquote>¿Cómo se instala?</blockquote><blockquote>Mi función es DevOps</blockquote><p><strong>DevOps</strong> (<a href="https://es.wikipedia.org/wiki/Acr%C3%B3nimo">acrónimo</a> inglés de <em>development</em> -<a href="https://es.wikipedia.org/wiki/Desarrollo_de_software">desarrollo</a>- y <em>operations</em> -<a href="https://es.wikipedia.org/w/index.php?title=Operaciones_%28IT%29&amp;action=edit&amp;redlink=1">operaciones</a>-) es un conjunto de prácticas que agrupan el desarrollo de software ( <em>Dev</em> ) y las operaciones de TI (<em>Ops</em>). (<a href="https://es.wikipedia.org/wiki/DevOps"><em>fuentes Wikipedia</em></a>).</p><p>El fortalecer lo colaborativo entre las diferentes partes entre las personas, los procesos y el producto que se está desarrollando, permitiendo una entrega continua.</p><h4><strong>¿Por qué DevOps?</strong></h4><p>Algunos motivos del porque pensar en esta filosofía</p><p><strong>Colaboración</strong>: Dev (desarrolladores) y Ops (operadores) trabajando juntos y compartiendo un mismo objetivo.</p><p><strong>Agilidad</strong>: las entregas son más rápidas y frecuentes en actualizaciones o nuevas funcionalidades dejando a los clientes más satisfechos en el mercado donde cada día es más competitivo.</p><p><strong>Automatización</strong>: las tareas repetitivas y en mantener el foco en la innovación, hace que las automatizaciones sea una mejoría y una actividad que da mucha productividad.</p><p><strong>Seguridad</strong>: técnicas de quienes practican el crimen cibernético está en constante aumento, y donde una fragilidad en un proyecto puede costar millones para las empresas. De ahí el surgimiento de DevSecOps donde aparte de la integración de desarrollo y operativa se incluye la de seguridad.</p><p>y un extenso etc.</p><h4>Recursos para los diferentes momentos DevOps</h4><p>Según en qué momento estemos en el ciclo de los diferentes pasos o pipeline (tubería donde fluyen las actividades) en DevOps, se puede asociar diferentes herramientas o tools.</p><p>Algunos ejemplos de Dev, para la planificación se puede nombrar a Trello o monday entre otros, así como en la parte de código Git, visual studio code, la parte de bluid o compilación a Jenkins, GitLab, teste puede nombrarse a Selenium o Sonarqube.</p><p>Y para Ops algunos ejemplos sería en release Docker, en Deploy a Terraform así como algunos proveedores cloud como AWS, etc. Para la operación Ansible, Vagrant, e como monitoramiento se puede citar a Prometheus, Grafana, etc</p><p>Entre los ejemplos existen varios, y con seguridad irán surgiendo otros, generando una amplia opción para los diferentes gustos de los consumidores.</p><p>Para los que tienen como hobbie la química, el site <em>ditial.io</em> lanzo un diseño bien interesante en forma de tabla periódica de los elementos, pero en este caso son las herramientas posibles para utilizar en DevOps, en este link puede observarse: <a href="https://digital.ai/learn/devsecops-periodic-table/"><em>digital.io devsecops-periodic-table</em></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ivKYiZ9bQxxwPVxDR9EsA.png" /></figure><h3>Conclusion</h3><p>La colaboración entre los diferentes integrantes de una organización en búsqueda de un resultado más rápido y de calidad es sin duda una de las prácticas más efectivas en foco a los objetivos.</p><p>Es unos de mis objetivos, de poder actuar como DevOps, este post es solo compartir diferentes datos que fui adquiriendo en estos meses de estudio.</p><p>¡¡¡Gracias por leer, y les deseo lo mejor siempre!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1fd120cdea40" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pipeline | Automation with Jenkins]]></title>
            <link>https://medium.com/@alejandrofuentesar/pipeline-automation-with-jenkins-867d5e0ada4b?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/867d5e0ada4b</guid>
            <category><![CDATA[dockerhub]]></category>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[gcp]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Thu, 02 Nov 2023 19:00:18 GMT</pubDate>
            <atom:updated>2023-11-02T19:00:18.527Z</atom:updated>
            <content:encoded><![CDATA[<p>GCP — Jenkins — GitHub — Docker HUB</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*Dz78caBrb56PcXHQljSudw.png" /></figure><p>Hi folks ! in this post, I to sharing my simple traveling with Pipelines. But based on real-world scenario.</p><p>The IT management of company where I work how DevOps Engineer, has returned from a conference and was impressed by the simplicity and power of an open-source tool that was presented to him, <a href="https://www.jenkins.io/">the <strong>J</strong>enkins</a>.</p><p>So, he requests me to prepare a demonstration using Jenkins to create capable of performing ‘<em>Build</em>’, ‘<em>Push</em>’, and ‘<em>Deploy</em>’ processes.</p><p>But how I work in a company, is normal that repository of applications are in a private on GitHub and the Docker images on Docker Hub.</p><p>Let’s go for this adventure and discovery this great tool called Jenkins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*ICLr_e8L0cVuI7Y-IaEHKw.png" /></figure><h3>But, before start, we’ll see some definitions</h3><p><strong>Pipeline</strong>: is a series of automated steps that software code goes through, from development to deployment. This help the development process to do more reliable and easier to manager.</p><p><strong>Jenkins</strong>: is a open-source automation server that helps automate various parts of the software development process. With it can create and manage pipeline, allowing developer to build, test, and deploy their code automatically. Jenkins is highly configurable and extensible, making a popular tool for Continuous Integration and Continuous Delivery (CI/CD).</p><p><strong>GitHub</strong>: is a web-based platform for version control and collaboration, primarily used for hosting and sharing software code. It allows developers to work together, and manage code repositories. GitHub offers features like issue tracking, code reviews, and integration with CI/CD tools.</p><p><strong>Docker Hub</strong>: is a cloud-based registry service for Docker containers. Like GitHub, Docker Hub is a repository too, but for Docker images. This service enables developers to share, distribute, and deploy containerized applications easily.</p><p><strong>Docker images</strong>: are lightweight, standalone, and executable packages that contain everything needed to run a piece of software.</p><h3>What will I do?</h3><blockquote>breath, and to go to step by step …</blockquote><p>Well, I will to create a Jenkins pipeline, but before, I need collect some answer how some premises:</p><p>How is the environment? Do I need for install Jenkins? And the private code GitHub, need token? Has I permission for Docker Hub? How Jenking link with them?</p><p>Some premises that I how DevOps can now imagine:</p><ul><li>I know that GitHub has a private repository</li><li>I know that Docker Hub has a private repository</li><li>I know that Jenkins need permission for communicate with GitHub and Docker Hub</li><li>I need to create permissions/credentials for GitHub and Docker Hub</li><li>I need to configuration theses permissions to Jenkins</li></ul><h3>Steps</h3><h4>Step 1 | GCP, creating the VM</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yochfGma7JViqsAgjNHeSQ.png" /></figure><p>In Google Cloud, I do create the VM with next specifications:</p><pre># Jenkins -&gt; jk<br>name: jk-server<br>region: us-central1 (Iowa)<br>zone: us-central1-c<br>VM: E2<br>OS: ubuntu 22.04 LTS</pre><h4>Step 2 | Install several tools on the VM</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nneh2BPAmeYeYcz43RCXdw.png" /></figure><p>After access in the CLI VM from SSH, I do executing several instructions for to preparing my environment such kind update and install java, Jenkins, docker, on so.</p><p><strong>Update OS and install Java</strong></p><pre># update apt<br>sudo apt update -y<br># install java<br>sudo apt install openjdk-11-jre -y </pre><p><strong>Install Jenkins</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H7UnrZ_1-xA-xn9WU-1jdA.png" /></figure><pre># now preapare the keys that Jenkins need for to install<br>curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \<br>  /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null<br>  <br>echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \<br>  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \<br>  /etc/apt/sources.list.d/jenkins.list &gt; /dev/null<br><br># update again for bring possible jenkins repositorios update<br>sudo apt update -y<br></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hjns9oedGjOFRgZaQZ5k1Q.png" /></figure><pre># install Jenkins<br>sudo apt install jenkins -y  <br>jenkins --version<br><br># prepare Jenkins for restar together to OS.<br>systemctl is-enabled jenkins<br>sudo systemctl enable jenkins<br><br># &#39;q&#39; para sair!<br>systemctl status jenkins</pre><p>I go to testing Jenkins in the browser from the VM (<em>I need to verify that the VM has the port tcp:8080 to </em>listening)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g_2jgK90axp76UwxWqANew.png" /></figure><p>Next, Install the suggested plugins, and create a Admin user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hnRHf3RsNt9bgokkfZaI3w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sZcBiuu_geH8D46ixXFhOg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehHfz4qIXqVYNbIAqH7Ofw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mdkIK4K2diX5HHnNsjUWog.png" /></figure><p><strong>Install Docker</strong></p><p>Now I need install docker for create images and push for Docker Hub.</p><pre># get script for install Docker<br>curl -fsSL https://get.docker.com -o get-docker.sh<br><br># Executing script<br>sudo sh get-docker.sh<br><br># after install, verify<br>docker -v<br>docker ps  | @error<br><br># Add user logged for to group docker<br>sudo usermod -aG docker $USER &amp;&amp; sudo systemctl restart docker<br><br># I need restart Shell for get updating</pre><h4>Step 3 | Creating Credentials</h4><p><strong>Docker Hub : Create a Token/Credentials</strong></p><p>Generate the <em>New Access Token</em> and save it in secure place, this will use i next step where will set credentials in Jenkins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UxW8I-TUzMaAHcg2HwJZ3Q.png" /></figure><p><strong>GitHub : Create Private Repository and Personal Access Token (PAT)</strong></p><p>First, I to create private repository in GitHub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmMHEQuIiqsbLKfD8F1jvw.png" /></figure><p>Next, I to create the PAT for Jenkins can communicate with this project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bBsjoE15PP6iP7flOu1qZw.png" /></figure><p>After select the button <em>Generate new token</em>, a new options appears.</p><p>How name I set <em>jk-to-gh-tk </em>and to expire to next day</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*e3bSsIjXy05JL0wmrM3lBQ.png" /></figure><p>I will select what repository I to set permissions and what kind of permissions</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s--scgffklx19nNZYEUVEA.png" /></figure><p>Only one observation, for default of settings in GitHub, when selected <strong>Contents</strong> permission, for it do correct work, GitHub activate <strong>Metadata</strong> too permission automatically with <em>Read-only</em> permission.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*017Arj9lNxyh_9ayFSwlFw.png" /></figure><p>After to generate the <em>PAT</em> save it in secure place</p><p><strong>Jenkins : Link with Docker Hub and GitHub</strong></p><p>The link with <strong>Docker Hub</strong>, add a credential, set the next:</p><p>user: user of docker, in password: the token the Docker Hub was generated, and in ID: the description that use when I did create Access Tokens</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p_0U8fCJgty2mcEF42RnXg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FeAogRecRa6SAqFv9BCQ5w.png" /></figure><p>The link with <strong>GitHub</strong>, the same to previous step, use the same user of GitHub, the PAT generated in GitHub, and in ID use the ‘<em>take name’</em> used when PAT was do created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*98yN8YaLcxdilUmwTZhjqg.png" /></figure><h4>Step 4 | Create pipelines</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uU76knpdNIbIbvR9LgXWJA.png" /></figure><p>For get from GitHub, I will create the file <em>Jenkinsfile</em> in the root path of my repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W0ofiDmt-b22Lxpckz3QAg.png" /></figure><p>Add next instruction inner <em>jenkinsfile</em></p><pre>pipeline {<br>    agent any<br><br>    stages {<br>        stage(&#39;SCM Checkout&#39;) {<br>            steps {<br>                git branch: &#39;main&#39;, credentialsId: &#39;jk-gh-tk&#39;, url: &#39;https://github.com/devopscloudbootcamp/jk-private-gh.git&#39;<br>            }<br>        }<br>    }<br>}</pre><p>Well, now my first <em>Build to test</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jYYsvkDFG8-cLRh_Wlk_Og.png" /></figure><p>One observation, Jenkins can’t user docker, I need to associate user Jenkins to Docker group</p><pre># set permissao jenkins inner group Docker<br>jenkins --version<br>2.414.3<br><br># see jenkins user<br>less /etc/passwd | grep jenkins<br>jenkins:x:114:122:Jenkins,,,:/var/lib/jenkins:/bin/bash<br><br># add junkins user in to docker group<br>sudo usermod -aG docker jenkins<br>grep docker /etc/group<br>docker:x:999:ale_fuentes_misc,jenkins<br><br># need restart jenkins<br>sudo systemctl restart jenkins</pre><p>Now, I set all stages of Jenkins</p><pre>pipeline {<br>    agent any<br>    <br>    environment {<br>        DOCKERHUB_CREDENTIALS = credentials(&#39;jk-to-dh-tk&#39;)<br>    }<br><br>    stages {<br>        stage(&#39;SCM Checkout&#39;) {<br>            steps {<br>                git branch: &#39;main&#39;, credentialsId: &#39;jk-to-gh-tk&#39;, url: &#39;https://github.com/ale-fuentes-ar/devops-jk-private-prj-gh.git&#39;<br>            }<br>        }<br>        <br>        stage(&#39;Build Docker Image&#39;) {<br>            steps {<br>                sh &#39;docker build -t alejafuentes/webapp:$BUILD_NUMBER .&#39;<br>            }<br>        }<br>        <br>        stage(&#39;Login to Docker Hub&#39;) {<br>            steps {<br>                sh &#39;echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin&#39;<br>            }<br>        }<br>        <br>        stage(&#39;Push Image to Docker Hub&#39;) {<br>            steps {<br>                sh &#39;docker push alejafuentes/webapp:$BUILD_NUMBER&#39;<br>            }<br>        }<br>        <br>        stage(&#39;Deploy Application&#39;) {<br>            steps {<br>                sh &#39;docker run --rm -d -p 3000:3000 --name webapp_ctr alejafuentes/webapp:${BUILD_NUMBER}&#39;<br>            }<br>        }<br>    }<br>}</pre><p>build now again</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3DMluHNkrelY0cR2TluUbw.png" /></figure><p>Check if the project can see from VM port 3000</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NKJITBA3HwE1sZ3O3q8yQQ.png" /></figure><h3>Conclusion</h3><p>I can see that the combining Google Cloud Platform (GCP), Jenkins, Docker Hub, and GitHub can create a powerful and efficient workflow for software development, continuous integration, and deployment.</p><p>GCP provides a scalable and reliable cloud infrastructure, while Jenkins serves as an automation server to build and deploy code. Docker Hub offers a centralized repository for containerized applications, and GitHub is a collaborative platform for managing and version controlling your code.</p><p>For philosophy DevOps, this tools are a good based for increment pipeline concept in ours projects.</p><p>Thanks for reading.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=867d5e0ada4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RxJS | sharing data with angular]]></title>
            <link>https://medium.com/@alejandrofuentesar/rxjs-sharing-data-with-angular-04b7d8fe598c?source=rss-891474d3ec4e------2</link>
            <guid isPermaLink="false">https://medium.com/p/04b7d8fe598c</guid>
            <category><![CDATA[rxjs]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[Alejandro Fuentes]]></dc:creator>
            <pubDate>Sat, 14 Oct 2023 01:21:24 GMT</pubDate>
            <atom:updated>2023-10-14T01:21:24.494Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Angular | RxJS BehaviorSubject</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*5MC3qF9nmGUT4WoBYt3rfQ.png" /></figure><p>Reactive programming is a programming paradigm that deals with asynchronous data streams and the propagation of changes.</p><p>In Angular several times I needed to handle communication between components, but when these components are at different levels deep in the project structure, the sharing is more difficult to flow information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/865/1*vHuH4wWKCgcPdIXbwFfIiQ.png" /></figure><h4>Reactive Programming</h4><p>Reactive programming is all about reacting to changes in data and events in a non-blocking, asynchronous way. In a reactive system, data flows through streams, and you can react to these streams by defining operations to be performed when new data arrives.</p><p>One of the key tools for implementing reactive programming is RxJS.</p><h4>RxJS</h4><p><a href="https://rxjs.dev/">RxJS (<strong><em>R</em></strong><em>eactive E</em><strong><em>x</em></strong><em>tensions for </em><strong><em>J</em></strong><em>ava</em><strong><em>S</em></strong><em>cript</em>)</a>, is a library that brings the principles of reactive programming to JavaScript.</p><p>It’s widely used in Angular applications for handling asynchronous operations, event handling, and data streams.</p><h4>Store component</h4><p>In RxJS has a component that I use to create an architecture of sharing data between components, BehaviorSubject is a crucial part of it, it can break down the concept and show how to use it for communication between Angular components.</p><p>The next architecture shows how the Store component gets news data, and other components can subscribe to get it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTarXwf7O5lFZIQPy0Ngdg.png" /></figure><h3>Steps</h3><blockquote>This example is an Angular project, for it I prepared my environment with the next tools such as <a href="https://nodejs.org/en">Node</a>, <a href="https://www.npmjs.com/">NPM</a>, <a href="https://angular.io/cli">AngularCLI</a>, <a href="https://code.visualstudio.com/">VSCode</a>.</blockquote><h4>Step 1 | Understanding the project</h4><p>This project is a simple listing of products, with its name, description and photo. So I can select each of these products, and when I do it the system shows me how much to select.</p><p>It will also list the selected products in another component, where can see the miniature image.</p><p>The idea is to create a store service, that has all products that the user selects, this property will be a promise. Then all components that need to see store service, only to subscribe to get all its data.</p><h4>Step 2 | Create Store service</h4><p>Store service is necessary for other components can see the data flow from it.</p><pre># create service &#39;store&#39; inner the &#39;services&#39; path<br>ng g s services/store</pre><blockquote><strong>BehaviorSubject </strong>is a type of RxJS Subject, it is a way to multicast a single source of data or events with multiple subscribers.</blockquote><pre>import { Injectable } from &#39;@angular/core&#39;;<br>import { BehaviorSubject } from &#39;rxjs&#39;;<br><br>import { Product } from &#39;../models/product&#39;;<br><br>@Injectable({<br>  providedIn: &#39;root&#39;<br>})<br>export class StoreService {<br><br>  // this list where I save the product selected by the user<br>  private myList: Product[] = [];<br>  // this is myBag where all selected product flow<br>  private myBag = new BehaviorSubject&lt;Product[]&gt;([]);<br><br>  // this is my observable object, where all components can see the products flow<br>  myBag$ = this.myBag.asObservable();<br><br>  constructor() { }<br><br>  addProduct(product: Product){<br>    // add a new product in my bag<br>    this.myList.push(product);<br>    // emmit and update my behaviorSubject object the &#39;myBag&#39;.<br>    this.myBag.next(this.myList);<br>  }<br><br>}</pre><h4>Step 3| Injection Store service in other components</h4><p><strong>This example is when I add a product to my observable</strong></p><pre>import { Component, OnInit } from &#39;@angular/core&#39;;<br>import { Product } from &#39;src/app/models/product&#39;;<br>import { ProductsService } from &#39;src/app/services/products.service&#39;;<br>// importing dependenci of Store service<br>import { StoreService } from &#39;src/app/services/store.service&#39;;<br><br>@Component({<br>  selector: &#39;app-products&#39;,<br>  templateUrl: &#39;./products.component.html&#39;,<br>  styleUrls: [&#39;./products.component.css&#39;]<br>})<br>export class ProductsComponent implements OnInit {<br><br>  private products: Product[] = [];<br><br>  constructor(<br>    private productService: ProductsService,<br>    // injecting Store service in my component<br>    private storeService: StoreService,<br>  ) { }<br><br>  ngOnInit() {<br>    this.getProducts();<br>  }<br><br>  getProducts() {<br>    this.productService.getProducts().subscribe(data =&gt; {<br>      this.products = data;<br>    });<br>  }<br><br>  addProductToBag(product: Product) {<br>    // add product in my Observable<br>    this.storeService.addProduct(product);<br>  }<br>}</pre><p>A slide of the template:</p><pre>&lt;div class=&quot;card-body&quot;&gt;<br>    &lt;h5 class=&quot;card-title&quot;&gt;{{ product.title }}&lt;/h5&gt;<br>    &lt;p class=&quot;card-text&quot;&gt;{{ product.description }}&lt;/p&gt;<br>    &lt;!-- this click call method that add new product in Store service --&gt;<br>    &lt;button (click)=&quot;addProductToBag(product)&quot; class=&quot;btn btn-primary&quot;&gt;Add to Bag&lt;/button&gt;<br>&lt;/div&gt;</pre><p><strong>This example is when I see the flow of products</strong></p><p>One example where I injected my Store service into one component:</p><pre>import { Component, OnInit } from &#39;@angular/core&#39;;<br><br>// importing dependenci of Store service<br>import { StoreService } from &#39;src/app/services/store.service&#39;;<br><br>@Component({<br>  selector: &#39;app-sidebar&#39;,<br>  templateUrl: &#39;./sidebar.component.html&#39;,<br>  styleUrls: [&#39;./sidebar.component.css&#39;]<br>})<br>export class SidebarComponent implements OnInit {<br><br>  // See subscribe form Store service<br>  myBag$ = this.storeService.myBag$;<br><br>  constructor(<br>    // injecting Store service in my component<br>    private storeService: StoreService,<br>  ) { }<br><br>  ngOnInit() {<br>  }<br><br>}</pre><p>And use it on the template of the component, in this case, I use pipeAsync :</p><pre>&lt;div class=&quot;item-product&quot; *ngFor=&quot;let product of (myBag$  | async)&quot;&gt;<br>    &lt;img [src]=&quot;product.images[0]&quot; alt=&quot;&quot;&gt;<br>    &lt;p&gt;{{ product.title }}&lt;/p&gt;<br>&lt;/div&gt;</pre><p>Repository <a href="https://github.com/ale-fuentes-ar/rxjs-storepattern">HERE</a></p><h3>Conclusion</h3><p><em>What is the difference between Components and Services in angular?</em><br>The service is singleton. It means if I want to use a repository in my application that persists data then I use Service. On the other hand, the Component is volatile, which means that when I change the URL, the component ends up losing all the data it has.</p><p>By taking advantage of this service feature and implementing BehaviorSubject in the Angular application, I can manage data more efficiently, and maintain a single source of truth and ensure that components have access to the latest data, making the application more solid, and receptive.</p><p>Thank you for reading…!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04b7d8fe598c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>