<?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: Istvan Kreisz</title>
    <description>The latest articles on DEV Community by Istvan Kreisz (@istvankreisz).</description>
    <link>https://dev.to/istvankreisz</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%2F332488%2Ff99e6e09-1e4f-456f-88e6-00429b2798cc.jpeg</url>
      <title>DEV Community: Istvan Kreisz</title>
      <link>https://dev.to/istvankreisz</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/istvankreisz"/>
    <language>en</language>
    <item>
      <title>How I built a simple "stock analytics" site with web scraping and serverless functions</title>
      <dc:creator>Istvan Kreisz</dc:creator>
      <pubDate>Sun, 07 Feb 2021 04:07:32 +0000</pubDate>
      <link>https://dev.to/istvankreisz/how-i-built-a-simple-stock-analytics-site-with-web-scraping-and-serverless-functions-3gma</link>
      <guid>https://dev.to/istvankreisz/how-i-built-a-simple-stock-analytics-site-with-web-scraping-and-serverless-functions-3gma</guid>
      <description>&lt;h2&gt;
  
  
  A little backstory: the GameStop short squeeze
&lt;/h2&gt;

&lt;p&gt;Everyone who even just loosely follows american news must have heard of the craziness going on on the US stock market in the past few weeks. In short the story is that a large group of Reddit users from the &lt;a href="https://www.reddit.com/r/wallstreetbets/"&gt;WallStreetBets&lt;/a&gt; subreddit, which describes itself as "a community for making money and being amused while doing it. Or, realistically, a place to come and upvote memes when your portfolio is down." almost brought Wall Street to its knees. They discovered that the GameStop stock was massively overshorted by a number of large hedge funds and in an effort to stick it to those greedy Wall Street investors they decided to start mass buying the company's shares. This drove up the stock's price so much that some hedge funds lost billions and needed to be bailed out to avoid bankruptcy. There's more to the story than this but let's get to the topic of the article.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r0D24S81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jt9h3tcgq9p6as986uzq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r0D24S81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jt9h3tcgq9p6as986uzq.jpg" alt="The GameStop rally"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  We Like The Stock!
&lt;/h2&gt;

&lt;p&gt;Okay, I admit calling &lt;a href="https://welikethestock.live"&gt;WeLikeTheStock.live&lt;/a&gt; a stock analytics site is a bit generous for this ridiculous looking meme site. My goal was not to build a &lt;a href="https://finance.yahoo.com/"&gt;Yahoo Finance&lt;/a&gt; competitor, but be a small part of this historic movement and build something that can bring a smile to some disgruntled Reddit investors' faces.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SIgwML-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/75gth85grtcciz620rnt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SIgwML-Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/75gth85grtcciz620rnt.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Web scraping, serverless functions and serverless database
&lt;/h2&gt;

&lt;p&gt;I've been a heavy user of &lt;a href="https://reactjs.org/"&gt;React&lt;/a&gt; and &lt;a href="https://nextjs.org/"&gt;Next.js&lt;/a&gt; so they were obvious choices for this project as well. Next.js makes the development of React sites a breeze with many useful features such as static &amp;amp; server side rendering, easy routing etc. If you use their own hosting solution, &lt;a href="https://vercel.com/"&gt;Vercel&lt;/a&gt; and hook it up to your site's repository then the whole deployment process is as easy as just pushing your changes to GitHub (or BitBucket or GitLab). Vercel also has built-in support for serverless functions which you can write in the same repo as your frontend code and push it to production along with your site. It doensn't get much easier than that!&lt;/p&gt;

&lt;p&gt;For the web scraping part I went with &lt;a href="https://www.scraperapi.com/"&gt;Scarper API&lt;/a&gt; which is another wonderfully simple to use framework, allowing developers to easily grab the HTML content from any page.&lt;/p&gt;

&lt;p&gt;I used &lt;a href="https://lambda.store/"&gt;Lambda Store&lt;/a&gt; to store data, which is a serverless database solution which takes only a few clicks to set up. It was my first time using it but I was suprised at the simplicity of it. It may not be suitable for a large scale application but it was perfect for my needs here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hooking it all up
&lt;/h2&gt;

&lt;p&gt;So we've got everything we need but how does it all come together to form this gorgeous looking website? Well the frontend code is not much to look at, the juicy part is the serverless function. It's one simple endpoint which provides the data to the site through Next.js's &lt;a href="https://nextjs.org/docs/basic-features/data-fetching#getserversideprops-server-side-rendering"&gt;&lt;code&gt;getServerSideProps&lt;/code&gt;&lt;/a&gt; function, which lets you pre-render the page on each request before serving it to the user. This function is an &lt;code&gt;async&lt;/code&gt; function which can go and fetch data or do any kind of work before returning the result which will be passed in as render props to the React site.&lt;/p&gt;

&lt;p&gt;The serverless function itself does the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  It checks the Redis database for recently updated data.&lt;/li&gt;
&lt;li&gt;  If it doesn't find anything or if the data is out of date (older than 20 mins), it goes ahead and scrapes &lt;a href="https://www.highshortinterest.com/"&gt;https://www.highshortinterest.com/&lt;/a&gt; which is a site listing the most shorted stocks. Scraper API takes care of all the scraping work, returning just the raw HTML code.&lt;/li&gt;
&lt;li&gt;  With the help of &lt;a href="https://github.com/chishui/JSSoup"&gt;JSSoup&lt;/a&gt; it pulls out the data from the HTML and transforms it into a JSON object.&lt;/li&gt;
&lt;li&gt;  Once that's done it saves the new data to the database, and returns it for the frontend to use.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's how you build a site using web scraping and serverless functions in no time! While this toolset would not scale well for larger applications, it's best not to overcomplicate things when all we want is a simple website that will break America's financial system.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://welikethestock.live"&gt;Go check it out now!&lt;/a&gt;
&lt;/h2&gt;

</description>
      <category>webdev</category>
      <category>nextjs</category>
      <category>serverless</category>
      <category>redis</category>
    </item>
    <item>
      <title>Do you like GeoGuessr? I built a multiplayer version of it (in React) that you need to try.</title>
      <dc:creator>Istvan Kreisz</dc:creator>
      <pubDate>Thu, 15 Oct 2020 15:11:29 +0000</pubDate>
      <link>https://dev.to/istvankreisz/do-you-like-geoguessr-i-built-a-multiplayer-version-of-it-in-react-that-you-need-to-try-1l8</link>
      <guid>https://dev.to/istvankreisz/do-you-like-geoguessr-i-built-a-multiplayer-version-of-it-in-react-that-you-need-to-try-1l8</guid>
      <description>&lt;h2&gt;
  
  
  Geo... what?
&lt;/h2&gt;

&lt;p&gt;In case you don't know &lt;a href="https://geoguessr.com" rel="noopener noreferrer"&gt;GeoGuessr&lt;/a&gt; is an online game where you're dropped somewhere on Earth and with the help of Google Street View you need to figure out where you are. It's a very popular online game and a personal favorite of mine.&lt;/p&gt;

&lt;h2&gt;
  
  
  So why make another one?
&lt;/h2&gt;

&lt;p&gt;A little background story: besides being a GeoGuessr fan, I've also spent countless hours playing .io-type online multiplayer games, like: &lt;a href="https://skribbl.io" rel="noopener noreferrer"&gt;skribbl.io&lt;/a&gt; and &lt;a href="https://slither.io" rel="noopener noreferrer"&gt;slither.io&lt;/a&gt;. The multiplayer element (among other things) makes these games a lot of fun and (unfortunately) highly addictive.&lt;/p&gt;

&lt;p&gt;And that's what's missing from GeoGuessr.. Don't get me wrong it's a great game, but I figured it could be even greater if it had some sort of multiplayer functionality. So I built my own version of it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introducing... Hide &amp;amp; Seek World!
&lt;/h2&gt;

&lt;p&gt;In &lt;a href="https://hideandseek.world" rel="noopener noreferrer"&gt;Hide &amp;amp; Seek World&lt;/a&gt; you're up against real players instead of just getting computer-generated random locations.&lt;/p&gt;

&lt;p&gt;The game consists of a few turns, and in each turn there's one hider who selects a location somewhere in the world, and 1-5 seekers who try to guess the location based on Google Street View images.&lt;br&gt;
As a hider your goal is hide well because the better seekers are able to guess your location the less points you get. As a seeker you get more points if you guess better.&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%2Fi%2F0jy72bteopcoj8dx437k.jpg" 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%2Fi%2F0jy72bteopcoj8dx437k.jpg" alt="screenshot 1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The concept is similar to the popular children's game, hence the name. The exception is that you have a bigger playground here, the whole world. At the end of each round you can see the guesses of all the players and how far everyone was from the actual hiding place.&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%2Fi%2F03z9rg5mpa4tdry6cml2.jpg" 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%2Fi%2F03z9rg5mpa4tdry6cml2.jpg" alt="screenshot 2"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Game modes
&lt;/h2&gt;

&lt;p&gt;There's 2 game modes: Street View and Satellite. In Street View mode you hide by selecting a street view location somewhere and in Satellite mode your hiding spot is a zoomed in rectangular area on the surface of Earth. In Street View mode you need to be able to read visual cues about architectural styles, vegetation, people etc. to guess well, while Satellite mode relies more on your geographical knowledge.&lt;/p&gt;

&lt;p&gt;You can also create a private room and play against your friends, where you can customize more things like: how much time you have to make a guess or restrict the map to only certain countries.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I built it
&lt;/h2&gt;

&lt;p&gt;I built the frontend using Next.js &amp;amp; React, and the backend with Firebase services: Authentication, Realtime Database, FireStore, Functions, Analytics. For the maps &amp;amp; Street View related things I used Bing Maps and Google Maps APIs. Payments are handled with Stripe Checkout. The site is hosted on Netlify.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;a href="https://hideandseek.world" rel="noopener noreferrer"&gt;Go check it out now!&lt;/a&gt;
&lt;/h2&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>startup</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
