<?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>DEV Community: Danny Aziz</title>
    <description>The latest articles on DEV Community by Danny Aziz (@dannyaziz97).</description>
    <link>https://dev.to/dannyaziz97</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%2F138682%2F4ef7e89b-b893-436b-8104-186b7c781e53.jpg</url>
      <title>DEV Community: Danny Aziz</title>
      <link>https://dev.to/dannyaziz97</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dannyaziz97"/>
    <language>en</language>
    <item>
      <title>How the hell do I use my forked NPM package?</title>
      <dc:creator>Danny Aziz</dc:creator>
      <pubDate>Mon, 19 Aug 2019 11:33:44 +0000</pubDate>
      <link>https://dev.to/dannyaziz97/how-the-hell-do-i-use-my-forked-npm-package-4pei</link>
      <guid>https://dev.to/dannyaziz97/how-the-hell-do-i-use-my-forked-npm-package-4pei</guid>
      <description>&lt;p&gt;You can install your fork by doing &lt;code&gt;npm install github:[GITHUB_USERNAME]/[GITHUB_REPO]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;But the package won't work out of the box. Why?&lt;/p&gt;

&lt;p&gt;Most of the time the &lt;code&gt;/dist&lt;/code&gt; of the package is placed into the &lt;code&gt;.gitignore&lt;/code&gt;. So you need to build a packaged version of the package so your project can use it.&lt;/p&gt;

&lt;p&gt;To do this there are 2 methods. Only one worked for me.&lt;/p&gt;

&lt;h3&gt;
  
  
  Method 1 (The one that didn't work for me 🤷‍♀️)
&lt;/h3&gt;

&lt;p&gt;Inside your package.json you add a &lt;code&gt;postinstall&lt;/code&gt; that goes into your directly and runs &lt;code&gt;npm install&lt;/code&gt; and &lt;code&gt;npm run build&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  "scripts": {
    "postinstall": "cd node_modules/[PACKAGE_NAME] &amp;amp;&amp;amp; npm install &amp;amp;&amp;amp; npm run build"
  },
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now just run &lt;code&gt;npm install&lt;/code&gt; and your package &lt;em&gt;should&lt;/em&gt; be updated to your fork.&lt;/p&gt;

&lt;h4&gt;
  
  
  What if it doesn't work?
&lt;/h4&gt;

&lt;p&gt;For a package I was testing it out on, &lt;code&gt;npm install&lt;/code&gt; worked perfectly but the build process would never work if the package was already inside node_modules...&lt;/p&gt;

&lt;h3&gt;
  
  
  Method 2 (Branch method)
&lt;/h3&gt;

&lt;p&gt;This method requires you to make a branch on your fork that will only be used for installing (until the master of your fork gets merged, hopefully)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Create a new branch:&lt;br&gt;
&lt;code&gt;git checkout -b useLocally&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Remove &lt;code&gt;/dist&lt;/code&gt; from the &lt;code&gt;.gitignore&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add the &lt;code&gt;build&lt;/code&gt; command to &lt;code&gt;precommit&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt; "precommit": [
     "build"
   ],
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Push Branch&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add *
git commit -m "COMMIT_MESSAGE_HERE"
git push origin useLocally
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now install the branch into your project&lt;br&gt;
Just append #[BRANCH_NAME] to the URL of the repo when installing&lt;br&gt;
&lt;code&gt;npm install github:[GITHUB_USERNAME]/[GITHUB_REPO]#[BRANCH_NAME]&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Now the &lt;code&gt;/dist&lt;/code&gt; will be installed without having to make any changes to the &lt;code&gt;package.json&lt;/code&gt; on master!&lt;/p&gt;

</description>
      <category>npm</category>
      <category>javascript</category>
      <category>react</category>
      <category>node</category>
    </item>
    <item>
      <title>Serverless Web Scraping With Python, AWS Lambda and Chalice</title>
      <dc:creator>Danny Aziz</dc:creator>
      <pubDate>Wed, 24 Jul 2019 12:10:13 +0000</pubDate>
      <link>https://dev.to/dannyaziz97/serverless-web-scraping-with-python-aws-lambda-and-chalice-42d4</link>
      <guid>https://dev.to/dannyaziz97/serverless-web-scraping-with-python-aws-lambda-and-chalice-42d4</guid>
      <description>&lt;h1&gt;
  
  
  Intro
&lt;/h1&gt;

&lt;p&gt;Programmatic and scalable web scraping is hard to do. There's a lot of build and maintenance involved that has nothing to do with the actual scraping task.&lt;/p&gt;

&lt;p&gt;Serverless computing makes it quite a lot easier.&lt;/p&gt;

&lt;p&gt;All you need to worry about is scraping the website in a friendly manner.&lt;br&gt;
Let's jump into creating a serverless web scraper with Python and hosting it on AWS Lambda by using Chalice to do all the heavy lifting for us. &lt;/p&gt;

&lt;p&gt;We are going to create a small scraper that returns today's #1 product on ProductHunt. (BTW: this is 100% doable using the ProductHunt API)&lt;/p&gt;

&lt;p&gt;Here is the repo for the project: &lt;a href="https://github.com/DannyAziz/serverless-product-hunt-scraper" rel="noopener noreferrer"&gt;https://github.com/DannyAziz/serverless-product-hunt-scraper&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  1. Set up Dev environment 🛠
&lt;/h1&gt;

&lt;p&gt;Set up your python virtual environment and install chalice&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkivrtualenv serverless_scraping&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install chalice&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Make sure to install this dependency via pip, we will be using this to make our scraping life easier:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install requests_html&lt;/code&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  2. Set up Chalice with AWS 🔑
&lt;/h1&gt;

&lt;p&gt;You need to authenticate your machine with your AWS account. If you've done this before, move on to the next step.&lt;/p&gt;

&lt;p&gt;First, you need access keys, to get these: Go to the Security Credentials page from the dropdown in the top right corner&lt;/p&gt;

&lt;p&gt;Expand the "Access Keys" dropdown and click "Create New Access Key"&lt;/p&gt;

&lt;p&gt;Make sure to note these down somewhere as you won't be able to see these again.&lt;/p&gt;

&lt;p&gt;Now you need to save these keys into a AWS config file:&lt;/p&gt;

&lt;p&gt;Create the AWS config folder&lt;/p&gt;

&lt;p&gt;&lt;code&gt;mkdir ~/.aws&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Create and open a new file&lt;/p&gt;

&lt;p&gt;&lt;code&gt;nano ~/.aws/config&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Paste this in, making sure to replace the keys and region with your own keys and region&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[default]
aws_access_key_id=YOUR_ACCESS_KEY_HERE
aws_secret_access_key=YOUR_SECRET_ACCESS_KEY
region=YOUR_REGION (such as us-west-2, us-west-1, etc)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  3. Create Scraping Script 🕸
&lt;/h1&gt;

&lt;p&gt;Create the chalice project&lt;/p&gt;

&lt;p&gt;&lt;code&gt;chalice new-project producthunt-scraper&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Inside your chalice project there will be an app.py file, replace the file with the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from chalice import Chalice
from requests_html import HTMLSession

app = Chalice(app_name='producthunt-scraper')


@app.route("/product-hunt/top-product")
def get_top_product_product_hunt():
    session = HTMLSession()
    url = 'https://www.producthunt.com/'
    resp = session.get(url)

    product_list_containers = resp.html.find(".postsList_b2208")

    if len(product_list_containers) == 1:
        product_list = product_list_containers[0]
    else:
        product_list = product_list_containers[1]

    if product_list:
        top_product = product_list.find("li")[0]
        product_obj = {
            "name": top_product.find(".content_31491", first=True).find("h3", first=True).text,
            "url": "https://producthunt.com{url}".format(url=top_product.find("a", first=True).attrs["href"]),
            "description": top_product.find(".content_31491", first=True).find("p", first=True).text,
            "upvote_count": top_product.find(".voteButtonWrap_4c515", first=True).text,

        }
        return product_obj
    else:
        return {"error": "Product List Element Not Found"}



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

&lt;/div&gt;



&lt;p&gt;Let's break down the code a little.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9txb2gfv4h8k2occ8rua.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9txb2gfv4h8k2occ8rua.png" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;All serverless functions in chalice are regular python functions, they need an @app decorator applied to them for the function to be called. In this example, we are using @app.route as we want our function to be called when it's requested via HTTP but you could do @app.schedule to run the function on a schedule or the other methods which you can find out about here: &lt;a href="https://github.com/aws/chalice" rel="noopener noreferrer"&gt;https://github.com/aws/chalice&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpjw1ywxur2ld41bczob.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnpjw1ywxur2ld41bczob.png" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The main part of our function uses the requests_html package to do all the heavy lifting for parsing the HTML document and pulling out the elements based on class names and HTML tags.&lt;br&gt;
Finally, we either return an object which contains the top product or an error.&lt;/p&gt;

&lt;h1&gt;
  
  
  4. Deploy 🚀
&lt;/h1&gt;

&lt;p&gt;You can test this scraper out locally via the chalice local command, this will create a local server reachable via &lt;a href="http://localhost:8000" rel="noopener noreferrer"&gt;http://localhost:8000&lt;/a&gt; that you can test your endpoints with.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04fom271aomc3yoyh4m0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04fom271aomc3yoyh4m0.png" width="800" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you're ready to go, use this command: &lt;code&gt;chalice deploy&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Chalice will now take care of everything, including creating the AWS lambda function in the console and packaging up all the dependencies for AWS lambda to use.&lt;/p&gt;

&lt;h1&gt;
  
  
  5. Done 🎉
&lt;/h1&gt;

&lt;p&gt;The deploy command should have spat out a URL, this is the public reachable URL for your serverless function and for our ProductHunt scraper.&lt;br&gt;
You've just created your first serverless scraper!&lt;/p&gt;

&lt;h1&gt;
  
  
  More Reading 📖
&lt;/h1&gt;

&lt;p&gt;Check out the Chalice docs here - &lt;a href="https://github.com/aws/chalice" rel="noopener noreferrer"&gt;https://github.com/aws/chalice&lt;/a&gt;&lt;br&gt;
Check out the AWS Lambda docs here - &lt;a href="https://docs.aws.amazon.com/lambda/latest/dg/welcome.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/lambda/latest/dg/welcome.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This post was originally created seen over at &lt;a href="https://blog.dannyaziz.com" rel="noopener noreferrer"&gt;https://blog.dannyaziz.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>serverless</category>
      <category>scraping</category>
      <category>python</category>
      <category>aws</category>
    </item>
    <item>
      <title>What is your biggest cause of bugs?</title>
      <dc:creator>Danny Aziz</dc:creator>
      <pubDate>Wed, 10 Jul 2019 10:19:24 +0000</pubDate>
      <link>https://dev.to/dannyaziz97/what-is-your-biggest-cause-of-bugs-5a51</link>
      <guid>https://dev.to/dannyaziz97/what-is-your-biggest-cause-of-bugs-5a51</guid>
      <description>&lt;p&gt;Recently I've found a lot of bugs have been caused by &lt;em&gt;my&lt;/em&gt; lack of attention to detail.&lt;/p&gt;

&lt;p&gt;For example, I was passing in the wrong thing to mixpanel's &lt;code&gt;alias&lt;/code&gt; call which caused a month's worth of analytics data to be missing all of the events before a user signs up&lt;/p&gt;

&lt;p&gt;Do you think you are causing the bugs in your work? Why?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Deploying React With AWS Amplify Console</title>
      <dc:creator>Danny Aziz</dc:creator>
      <pubDate>Tue, 25 Jun 2019 19:05:09 +0000</pubDate>
      <link>https://dev.to/dannyaziz97/deploying-react-with-aws-amplify-console-3dka</link>
      <guid>https://dev.to/dannyaziz97/deploying-react-with-aws-amplify-console-3dka</guid>
      <description>&lt;h3&gt;
  
  
  TLDR:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Setting up AWS Amplify Console/Deploy is really familiar if you've used other CI/CD tools&lt;/li&gt;
&lt;li&gt;It doesn't just build your application but also deploys to a managed CloudFront distribution&lt;/li&gt;
&lt;li&gt;The build config might confuse you slightly if you're coming from something like CircleCI
Intro:
AWS Amplify is a new offering from AWS. It consists of two parts, a framework for creating applications that connects your app with AWS services and a CI/CD tool for deploying any application.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Today we will be talking about the deployment service of AWS Amplify.&lt;/p&gt;

&lt;p&gt;I stumbled upon AWS Amplify when researching the best way to do cache invalidation on CloudFront distributions.&lt;/p&gt;

&lt;p&gt;It turns out that AWS Amplify does instant invalidations on every deploy! (Click here to read more about it)&lt;/p&gt;

&lt;p&gt;I'm going to walk you through setting up AWS Amplify with Github and deploying a Client Side Rendered React App.&lt;/p&gt;

&lt;p&gt;Let's go 🚀&lt;/p&gt;

&lt;h3&gt;
  
  
  Breakdown of Steps:
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Integrate Github 😸&lt;/li&gt;
&lt;li&gt;Connect Repo 🔌&lt;/li&gt;
&lt;li&gt;Setup Build Config 🔨&lt;/li&gt;
&lt;li&gt;Build Config Gotchas ⚠️&lt;/li&gt;
&lt;li&gt;URL Redirects ↩️
Done! ✨ 🎉&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Integrate Github 😸
&lt;/h3&gt;

&lt;p&gt;Time Taken: 3 Minutes&lt;/p&gt;

&lt;p&gt;Like a lot of CI/CD tools, you connect AWS Amplify with Github (or other version control tools) and on each commit to the repo causes the build process to start.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4zmc43s6p9n6yi32znn4.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F4zmc43s6p9n6yi32znn4.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect Repo 🔌
&lt;/h3&gt;

&lt;p&gt;Time Taken: 1 minute&lt;/p&gt;

&lt;p&gt;Once you've set up your version control with AWS Amplify, you need to pick your repo and select a branch.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setup Build Config 🔨
&lt;/h3&gt;

&lt;p&gt;Time Taken: 5 - 10 minutes&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fm9vfjetpwmi8d2g9qunq.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fm9vfjetpwmi8d2g9qunq.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is where the magic begins. If you've used other CI/CD tools than you are familiar with this process.&lt;/p&gt;

&lt;p&gt;AWS Amplify will attempt to create a build config automatically, which you can download and place into your repo or edit on the console.&lt;/p&gt;

&lt;p&gt;If you have config files for other CI tools, AWS Amplify can also copy these automatically (This is a good and a bad thing)&lt;/p&gt;

&lt;h3&gt;
  
  
  Build Config Gotchas ⚠️
&lt;/h3&gt;

&lt;p&gt;There are a few gotchas that caused my initial builds to fail. I've gone through the pain, so you don't have to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;sudo&lt;/code&gt; Does not work - This is similar to other CI/CD tools&lt;/li&gt;
&lt;li&gt;The automatic config might pull things from configs from other CI tools like I said earlier this is a good and a bad thing. I had a lot of commands that were needed for CircleCI to build and deploy but not needed for AWS Amplify - Double check the automatic config.&lt;/li&gt;
&lt;li&gt;Build output directory - The warning is there and yet I ignored it. - -Make sure to change baseDirectory to your build processes output folder (Probably /build)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  URL Redirects ↩️
&lt;/h3&gt;

&lt;p&gt;If you're running a SPA (Create React App etc), then you will need to set up URL redirects.&lt;/p&gt;

&lt;p&gt;In the app project within the console, there will be settings in the left-hand side one of them will be for "Redirects and rewrites"&lt;/p&gt;

&lt;p&gt;Here's the basic one for SPA's:&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flrww6ds4bgjrxww26csa.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Flrww6ds4bgjrxww26csa.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Done! ✨ 🎉
&lt;/h3&gt;

&lt;p&gt;You should be done!&lt;/p&gt;

&lt;p&gt;AWS Amplify will deploy your app to CloudFront and give you a URL as well.&lt;/p&gt;

&lt;p&gt;Need to do more or having issues? Check out the links below&lt;/p&gt;

&lt;h3&gt;
  
  
  More Reading:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/amplify/latest/userguide/welcome.html" rel="noopener noreferrer"&gt;Welcome Guide&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html" rel="noopener noreferrer"&gt;URL Redirects&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/amplify/latest/userguide/custom-domains.html" rel="noopener noreferrer"&gt;Custom Domains&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;This post was originally posted on &lt;a href="https://blog.dannyaziz.com" rel="noopener noreferrer"&gt;https://blog.dannyaziz.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>ci</category>
      <category>cd</category>
      <category>amplify</category>
    </item>
    <item>
      <title>How do you create static-sites for your dynamic JS projects?</title>
      <dc:creator>Danny Aziz</dc:creator>
      <pubDate>Sat, 23 Feb 2019 12:28:02 +0000</pubDate>
      <link>https://dev.to/dannyaziz97/how-do-you-create-static-sites-for-your-dynamic-js-projects-n6p</link>
      <guid>https://dev.to/dannyaziz97/how-do-you-create-static-sites-for-your-dynamic-js-projects-n6p</guid>
      <description>&lt;p&gt;So I've got a preact SPA app and I want to create static-sites for some content (The content only updates a few times a year and new content is only added once a week)&lt;/p&gt;

&lt;p&gt;Currently, I am using &lt;code&gt;prerenderer-webpack-plugin&lt;/code&gt; to prerender all of the routes I require on a build and then using webhooks with Netlify to build on changes.&lt;/p&gt;

&lt;p&gt;I'd love to know how other people are approaching this?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Listen to the god damn warnings.</title>
      <dc:creator>Danny Aziz</dc:creator>
      <pubDate>Fri, 22 Feb 2019 17:44:41 +0000</pubDate>
      <link>https://dev.to/dannyaziz97/listen-to-the-god-damn-warnings-3ld1</link>
      <guid>https://dev.to/dannyaziz97/listen-to-the-god-damn-warnings-3ld1</guid>
      <description>&lt;p&gt;(Most) Developers are not silly people, they know what they are doing. So when you (I) are using an open source project and there's a warning that appears, listen to it.&lt;/p&gt;

&lt;p&gt;A couple of weeks back I was trying to integrate Elasticsearch into a Django project of mine. Setting up on my local machine was fine as I was using &lt;code&gt;django-elasticsearch-dsl&lt;/code&gt; which does all the heavy lifting for you.&lt;/p&gt;

&lt;p&gt;Deploying onto my server was a different story...&lt;/p&gt;

&lt;p&gt;I had 800,000 objects that I wanted to keep in sync with Django and Elasticsearch, locally this was fine but on my AWS t3.medium server it wouldn't work.&lt;/p&gt;

&lt;p&gt;Firstly, the server would become unresponsive when trying to sync - too much RAM usage so I used the &lt;code&gt;queryset_pagination&lt;/code&gt; argument to paginate my objects for syncing (Instead of syncing all the objects in one go, it would sync them in bunches).&lt;/p&gt;

&lt;p&gt;🎉It's syncing!&lt;/p&gt;

&lt;p&gt;30 minutes pass and it's time to check and guess what? There are only around 400,000 objects. Only half of the objects synced! This didn't happen on my local machine which had a copy of the same database, how could this be happening?&lt;/p&gt;

&lt;p&gt;Next, I thought Elasticsearch was using up too much RAM and so I separated Django and Elasticsearch onto different servers.&lt;/p&gt;

&lt;p&gt;⏳Time to sync again.&lt;/p&gt;

&lt;p&gt;500,000 - An extra 100,000 objects but not the 800,000 that I needed. This time I spent more time than I care to admit rummaging through documentation, GitHub issues and source code trying to understand how everything worked.&lt;/p&gt;

&lt;p&gt;I tried out different people's forks of &lt;code&gt;django-elasticsearch-dsl&lt;/code&gt; but even that didn't help.&lt;/p&gt;

&lt;p&gt;and then I saw it...&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Pagination may yield inconsistent results with an unordered object_list&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This was a warning message that was constantly being displayed as I was syncing but for &lt;em&gt;some&lt;/em&gt; reason I ignored it. &lt;/p&gt;

&lt;p&gt;Put simply, the &lt;code&gt;queryset_pagination&lt;/code&gt; argument which was helping me save RAM (and was required to sync on the server) was the issue. &lt;code&gt;django-elasticsearch-dsl&lt;/code&gt; was putting all of the objects into bunches to be synced &lt;em&gt;but&lt;/em&gt; there was no order, so some objects were being synced more than once and some were being ignored.&lt;/p&gt;

&lt;p&gt;All I had to do was fork the repo and add one line of code: &lt;code&gt;.order_by("id")&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Finally, all was good in the world again 🎈&lt;/p&gt;

</description>
      <category>python</category>
      <category>elasticsearch</category>
      <category>django</category>
    </item>
  </channel>
</rss>
