Giter VIP home page Giter VIP logo

blog's Introduction

Hi there ๐Ÿ‘‹

blog's People

Contributors

dependabot-preview[bot] avatar dschau avatar gesposito avatar heinrichfilter avatar iamnishantmishra avatar irekrog avatar jackbravo avatar jumpalottahigh avatar kyleamathews avatar lgraubner avatar luandro avatar m-allanson avatar marcobiedermann avatar markcatley avatar mathiasbynens avatar mattbag avatar mef avatar meherhowji avatar mmeinzer avatar mottox2 avatar patrykkopycinski avatar pieh avatar pixelyunicorn avatar preetjdp avatar robinmetral avatar rstacruz avatar rsternagel avatar sethwilsonus avatar wesbos avatar wowu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

blog's Issues

Thoughts On hasura

Have been using using Hasura for Production at Devfolio for about 2 months now, here are my unfiltered thoughts.

  • Its very very good for a sliver of use cases, and it could not have done the job better
  • The authorisation system is kinda magical, giving a very good interpretation of the rules
  • Its easy enough to hit berries while building something big

Setting up this Blog.


title: 'Setting up this Blog.'
slug: 'setting-up-this-blog'
excerpt: 'Short outlook onto how this blog is setup'
date: '2020-06-20'

Alright, Hey there I'm gonna tell you how to set up this blog powered by Github Issues.
But before that the backstory. Ah heck Skip it

So on the 20th of June, Viranchee shared that he's building his blog entirely powered by Github Issues and linked to this blog as a reference.

The Blog My Reaction
My Reaction

And I really liked the idea, and immediately set out to get this working.

The Process.

Step 0 was to figure out what frontend to use, Gatbsy stood out because it favors GraphQL for data querying and I thought pairing it with the Github API should be seamless.

Arguably one of the best blogs out there is Overreacted By Dan Abramov. So step 1 was to just fork it out and figure it how it's working internally.

Overreacted uses The Remark Transformer Plugin to look for all the Markdown files in the project, process them and make them available to consume under GraphQL.

Well that's useless for us because we want to fetch markdown from Github, not from files on our computer.

Conveniently Gatsby has a Plugin to easily add external GrapqQL Datasources.

It was fairly simple to get data from the Github API. Pipe that with the Gatsby createPage Function, and that's basically the working of the blog.

Code that makes this work.
  // Fetch issues from GraphQL.
  const result = await graphql(
    `
      {
        github {
          viewer {
            repository(name: "Blog") {
              issues(first: 20) {
                nodes {
                  id
                  title
                  bodyHTML
                }
              }
            }
          }
        }
      }
    `
  )

  // Generate Pages for each Post.
  const posts = result.data.github.viewer.repository.issues.nodes
  posts.forEach((post, index) => {
    createPage({
      path: post.number.toString(),
      component: blogPost,
      context: {
        slug: post.number
      },
    })
  })

Steps for Setup.

  1. Set up the project locally.

Clone the project and install the dependencies.

git clone https://github.com/preetjdp/Blog
cd Blog
npm install
# If you get a libpng error while running this
# run `npm rebuild`
  1. Set up a Repo to host your Issues for the blog

Something like https://github.com/YOUR_NAME/Blog

  1. Get a Github Personal Token

A token can be obtained from this URL. Here are the options that I used.

image

  1. Running the Project.

Now that you've obtained your token just use it to run the app.

# If you're running Windows / Powershell
$env:GITHUB_TOKEN="GITHUB_TOKEN"
npm run develop

# If you're using Linux / MacOS
GITHUB_TOKEN="GITHUB_TOKEN" npm run develop

And that's it ๐ŸŽ‰๐ŸŽ‰. You should have a gatsby project running on http://localhost:8000

Wait How does this work? The Environment Variable is sent as a `Bearer` Auth Header to the Github API.

Authorization: `Bearer ${process.env.GITHUB_TOKEN}`

  1. Personalizing the Blog

Most of the configuration is done through the gatsby-config.js file.
You can change the fields here's as per your liking.

Blog/gatsby-config.js

Lines 2 to 12 in 530dfbb

siteMetadata: {
title: `Blog`,
author: `Preet Parekh`,
description: `Personal Blog`,
siteUrl: `https://preet-blog.netlify.app/`,
social: {
twitter: `TmPreet`,
mail: `[email protected]`
},
repoName: `Blog`
},

Quirks of this Approach.

The data is not loaded at runtime.

Wait Whaaaat?? What does this mean?
When you change the content of an issue (In the pursuit of editing a blog post). It won't work unless you build it afterward and publish it.

This is a blessing in disguise, this allows the blog to be ridiculously fast.
Lighthouse Test Result

References

Writing a Graph File system

Tldr.

I wrote a file system in rust, with the primary mode of interaction over GraphQL

All operations are to be executed over graphQL

Staying Eccentric


title: 'Staying Eccentric'
slug: 'staying-eccentic'
excerpt: 'A note to myself ๐Ÿ˜Œ'
date: '2020-07-13'

Dear Preet,
There will be moments in your life where you feel that everything has stagnated, you'll feel extremely bored and dumbed down.

At such a moment remember what pumps you up.
Remember that money is not important, it is essential to survival, but don't be pulled into something just because you're getting paid, and may mean you can buy something for yourself / purchase something for your mom.

Remember always you love to break things apart. You're the kind of person who before even fully understanding something takes a screw-driver to it -> Open's it apart and tries to piece it back together.

Whatever decision you make, make it with eccentricity, be pumped up to do it, or don't do it at all. The true value of you lies somewhere in there.

You're not good at studies, you're in a fucked up college, but there things that bring you up. You've met some remarkable people over time. And remember baba is always there.

If You DO read this, here are a couple of things that are interesting to do!

  1. Turn your old cycle to an electric cycle.

  2. Work at a Hydroponic Farm / Like freaking builds, patent, and license tech.
    How would this work? you ask.

There's a ton of fucking potential in terms of tech that can be built for Hydroponics.
"The truck thing that Kimbal Musk has built is pretty amazing" and I don't see any startups in India doing something similar to that. The real opportunity is when you realize that your family (kinda) is involved in the "Shipping" business.
This could be a great source of containers for the plants.

  1. You've grown an interest in making food, it might be fun to explore that

Stay Eccentric

Stagnation is the worst

The feeling of being lethargic and not being able to gain the energy to do something, to get work done is the worst feeling of all

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.