<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Robin Kiplangat</title>
    <description>The latest articles on Forem by Robin Kiplangat (@robinkiplangat).</description>
    <link>https://forem.com/robinkiplangat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1119898%2Fa93a966c-5182-4364-9b42-0d8f6f500555.jpg</url>
      <title>Forem: Robin Kiplangat</title>
      <link>https://forem.com/robinkiplangat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/robinkiplangat"/>
    <language>en</language>
    <item>
      <title>Decomposition.</title>
      <dc:creator>Robin Kiplangat</dc:creator>
      <pubDate>Mon, 20 May 2024 08:55:26 +0000</pubDate>
      <link>https://forem.com/robinkiplangat/decomposition-346f</link>
      <guid>https://forem.com/robinkiplangat/decomposition-346f</guid>
      <description>&lt;p&gt;In the world of data science, web scraping is a common method for gathering data from the internet. However, it can be a complex task, especially for those new to programming. &lt;br&gt;
This is where decomposition comes into play. It's a method that helps you understand the overall structure and logic of a program by presenting it in a simplified, step-by-step manner, making it more accessible to both techies and non-techies alike.&lt;/p&gt;

&lt;p&gt;In this post, we'll walk you through an example of how decomposition can be used to scrape data from a website.&lt;/p&gt;
&lt;h2&gt;
  
  
  What is decomposition.?
&lt;/h2&gt;

&lt;p&gt;Decomposition refers to the process of breaking down a large, complex tasks into smaller, more manageable subtasks. This approach simplifies the problem-solving process, making it easier to understand, design, and implement solutions. &lt;/p&gt;

&lt;p&gt;It involves creating a detailed plan, executing each step individually, and constantly reviewing and adjusting the plan as needed.&lt;/p&gt;

&lt;p&gt;This method is particularly useful in programming tasks, as it allows for better error handling and debugging.&lt;/p&gt;
&lt;h2&gt;
  
  
  The Task at Hand
&lt;/h2&gt;

&lt;p&gt;Our goal is to scrape data from pages on a website. We want to extract information such as the title, description, contact information, and images of each page.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Planning
&lt;/h2&gt;

&lt;p&gt;The first step is to create a detailed plan. For our task, the plan might look something like this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetch the HTML content of the webpage.&lt;/li&gt;
&lt;li&gt;Parse the HTML content to extract the required data.&lt;/li&gt;
&lt;li&gt;Save the extracted data in a structured format.&lt;/li&gt;
&lt;li&gt;Download the image of the initiative.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Step 2: Fetching the Webpage Content
&lt;/h2&gt;

&lt;p&gt;We'll use the requests library in Python to fetch the HTML content of the webpage. Here's a simple function that does this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fetch_page_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;text&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: Parsing the HTML Content
&lt;/h2&gt;

&lt;p&gt;Next, we'll use the BeautifulSoup library to parse the HTML content and extract the required data. We'll create a function called extract_data that takes the HTML content as input and returns a dictionary with the extracted data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;bs4&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;BeautifulSoup&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;extract_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html_content&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="n"&gt;soup&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;BeautifulSoup&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html_content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;html.parser&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="c1"&gt;# Extract the data…
&lt;/span&gt;&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;data&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Saving the Data
&lt;/h2&gt;

&lt;p&gt;Once we have the data, we can save it in a structured format. For simplicity, we'll just print the data for now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;url&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;urls&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;html_content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;fetch_page_content&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="n"&gt;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;extract_data&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;html_content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 5: Downloading the images
&lt;/h2&gt;

&lt;p&gt;Finally, we'll create a function to download the image of each initiative. We'll use the requests library again to fetch the image, and then save it to a file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;download_image&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
  &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;requests&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;.png&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;wb&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;write&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  So Now . .
&lt;/h2&gt;

&lt;p&gt;And that's it! With decomposition, we've broken down a complex task into manageable steps, making it easier to understand and execute. This method is not only useful for web scraping, but for any programming task. So next time you're faced with a complex task, give it a try!&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Navigating building AI products: A Step-by-Step Guide</title>
      <dc:creator>Robin Kiplangat</dc:creator>
      <pubDate>Wed, 01 Nov 2023 10:00:00 +0000</pubDate>
      <link>https://forem.com/aws-builders/navigating-building-ai-products-a-step-by-step-guide-594h</link>
      <guid>https://forem.com/aws-builders/navigating-building-ai-products-a-step-by-step-guide-594h</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Imagine having to go through a stack of lab reports, each filled with complex medical jargon and lengthy explanations. It’s a daunting task, isn’t it? But what if we could use Artificial Intelligence (AI) to simplify this process?&lt;/p&gt;

&lt;p&gt;In this blog post, I’ll guide you on how to create a tool that uses AI to read and summarize lab reports. This tool uses two key components: Langchain and OpenAI.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Langchain and OpenAI?
&lt;/h2&gt;

&lt;p&gt;Before we dive into the how-to, let’s understand what Langchain and OpenAI are. Langchain is a library that allows us to combine different AI models to perform complex tasks. Think of Langchain as a master chef who knows how to combine different ingredients (in our case, AI models) to create a delicious dish (a summary in our case 😋)&lt;/p&gt;

&lt;p&gt;OpenAI, on the other hand, is an AI research lab that provides powerful AI models. We use one of their models, GPT-3.5-turbo, to process the lab reports and generate a summary.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Magic Behind the Scenes
&lt;/h2&gt;

&lt;p&gt;Our tool consists of two parts: a backend script that processes the lab reports and a frontend script that provides a user interface. The backend script reads the text from a PDF file, identifies the key points using OpenAI, and then creates a summary using Langchain. The frontend script provides a user-friendly interface where you can upload your lab report, and displays the key points and the summary of the report.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building the AI Tool: A Step-by-Step Guide
&lt;/h2&gt;

&lt;p&gt;Now that we’ve set the stage, let’s get our hands dirty and start building this tool.&lt;/p&gt;

&lt;h3&gt;
  
  
  A. Backend Script
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Install the necessary libraries:&lt;/strong&gt; First, we need to install some libraries. If you’ve ever baked a cake, think of this step as gathering your ingredients. You can install the libraries using pip, which is a package manager for Python.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/robinkiplangat/LabScanner.git
cd LabScanner
pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Get your OpenAI API key&lt;/strong&gt;: To use OpenAI, you need an API key. You can get this key from the OpenAI website after creating an account.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run the backend script&lt;/strong&gt;: Once you have your ingredients ready, it’s time to start baking! You can run the backend script using Python.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python3 scripts/reports_frontend.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  B. Frontend Script
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Install Streamlit&lt;/strong&gt; : The frontend script is a Streamlit application. Streamlit is a library that allows you to create web applications using Python. You can install it using pip.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Run the frontend script&lt;/strong&gt; : Once you have installed Streamlit, you can run the frontend script. This will open a new tab in your web browser with the application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamlit run scripts/reports_frontend.py

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To use the application, upload a lab report, enter your OpenAI API key, and click Submit. Check out the demo below. &lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/F1KWrqLwJ-8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Set Up a Self Hosted Outline VPN with Amazon LightSail in 5 steps.</title>
      <dc:creator>Robin Kiplangat</dc:creator>
      <pubDate>Thu, 24 Aug 2023 07:22:43 +0000</pubDate>
      <link>https://forem.com/aws-builders/set-up-a-self-hosted-outline-vpn-with-amazon-lightsail-in-5-steps-2p85</link>
      <guid>https://forem.com/aws-builders/set-up-a-self-hosted-outline-vpn-with-amazon-lightsail-in-5-steps-2p85</guid>
      <description>&lt;p&gt;&lt;a href="https://getoutline.org/" rel="noopener noreferrer"&gt;Outline&lt;/a&gt;, a free and open-source VPN service developed by Google, is renowned for its user-friendly design. It can be conveniently established on diverse platforms, and this blog will specifically guide you through the process of setting up a self-hosted Outline VPN using Amazon LightSail.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before diving into the procedure, ensure you have the basics:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An active Amazon LightSail account.&lt;/li&gt;
&lt;li&gt;A computer equipped with a web browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Set Up the Outline Manager
&lt;/h2&gt;

&lt;p&gt;Kick-start your setup by downloading and installing the &lt;a href="https://getoutline.org/get-started/#step-1" rel="noopener noreferrer"&gt;Outline Manager&lt;/a&gt; desktop application. This is your control centre for establishing and managing your server.&lt;/p&gt;

&lt;p&gt;Post-setup, click on the &lt;em&gt;Add Server&lt;/em&gt; option to begin the process of creating your server , Then select the option for configuring the application on an AWS Linux server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Incorporate Outline on Your Amazon LightSail Instance
&lt;/h2&gt;

&lt;p&gt;Once the instance is created, the next step would be integrating the Outline server with your instance.&lt;br&gt;
For this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Head over to the &lt;a href="https://lightsail.aws.amazon.com/" rel="noopener noreferrer"&gt;Amazon Lightsail&lt;/a&gt; instances screen.&lt;/li&gt;
&lt;li&gt;Select the instance you wish to host Outline on and switch to the &lt;em&gt;Networking&lt;/em&gt; tab.&lt;/li&gt;
&lt;li&gt;In the &lt;em&gt;Firewall&lt;/em&gt; section, click &lt;em&gt;Add Rule&lt;/em&gt; and ;&lt;/li&gt;
&lt;li&gt;Assign &lt;code&gt;All Protocols&lt;/code&gt; a value of &lt;code&gt;All TCP+UDP&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Save the changes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff6a0hpjea5xco2bzr265.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff6a0hpjea5xco2bzr265.png" alt="Steps to setup Your Amazon LightSail Instance"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Establish Connection to Your Instance
&lt;/h2&gt;

&lt;p&gt;Choose your preferred method to connect to your instance; it could either be through your browser or an SSH client that aligns with your requirements.&lt;/p&gt;

&lt;p&gt;Next, connect to your server and execute the following command that can be traced back to the setup instructions offered in the manager:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;sudo &lt;/span&gt;bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;wget &lt;span class="nt"&gt;-qO-&lt;/span&gt; https://raw.githubusercontent.com/Jigsaw-Code/outline-server/master/src/server_manager/install_scripts/install_server.sh&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Follow the subsequent instructions to successfully install Outline on your instance.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Configuring the Outline Server
&lt;/h2&gt;

&lt;p&gt;With Outline now a part of your instance, it's time to configure it as per your requirements. To accomplish this, paste the installation output from your SSH session onto the manager and click &lt;em&gt;Done&lt;/em&gt; to finalize the configurations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdw8gfnqiz0elu1gesor.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwdw8gfnqiz0elu1gesor.png" alt="The code output includes the curly parenthesis {} as well.&amp;lt;br&amp;gt;
"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Adding and Connecting Keys
&lt;/h2&gt;

&lt;p&gt;With the server now configured, the next move involves adding keys and establishing a connection to the server.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F57zbpijdmut55e2rdr0o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F57zbpijdmut55e2rdr0o.png" alt="Add New keys using the Outline Manager"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Open the Outline application on your computer and provide the name and address of your server for this process. After successfully connecting to your server, utilize unhindered access to the internet through it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;This guide offers a comprehensive panorama of the process to set up a self-hosted Outline VPN with Amazon LightSail. Remember, this is a basic outline, and for more detailed understanding and troubleshooting, always refer to the &lt;a href="https://getoutline.org/get-started/" rel="noopener noreferrer"&gt;Outline documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>cybersecurity</category>
      <category>security</category>
      <category>data</category>
    </item>
  </channel>
</rss>
