Tuesday, February 23, 2021

Merge K sorted array

This is LeetCode problem 23: merge K sorted array.

The solution is to use heap to merge sub array.

I provide three kinds of solution. Use the second solution to pass LeetCode.



Saturday, February 20, 2021

Link Image in Linkedin

 I want to link my web site and github to linkedin, but I found a missing site thumbnail.

To fix that, I need to add tag like

<meta property="og:image" content="image url" />

in gatsby project > components > seo.js.

      meta={[
        {
          name: `description`,
          content: metaDescription,
        },
        {
          property: `og:title`,
          content: title,
        },
        {
          name: "image",
          property: `og:image`,
          content: thumbnail,
        },
        {
          name: "description",
          property: `og:description`,
          content: metaDescription,
        },
        {
          property: `og:type`,
          content: `website`,
        },
        {
          name: `twitter:card`,
          content: `summary`,
        },
        {
          name: `twitter:creator`,
          content: site.siteMetadata?.author || ``,
        },
        {
          name: `twitter:title`,
          content: title,
        },
        {
          name: `twitter:description`,
          content: metaDescription,
        },
      ].concat(meta)}

Since both title and description are data loaded from gatsby-config.js

So I try to add image into configuration. However, the image path can not be transpiled correctly.

The correctly way to do that is import image:

import thumbnail from '../images/monster.png' 

After redo, I have thumbnail shown now.







 

 

 

 




Monday, February 15, 2021

heroku deployment

 Few lessons I learned when I deployed react apps.

  1. Show to start up:
    Need to switch another buildpacks intead of heroku default node.js
    heroku buildpacks:set mars/create-react-app -a <appname>
  2. Error of no web process:
    at=error code=H14 desc="No web processes running" method=GET path="/"

    To solve it, run
    heroku ps:scale web=1

  3. PUBLIC_URL
    In the package.json, I have :
    "homepage": "http://mywebsite.com/relativepath"
    It's for deploying to github some time I did and I just forgot it.
    That took me a while to figure out.


Saturday, February 13, 2021

heroku cheat sheets

 Login

heroku login

 

Logs

heroku logs -a [app name] --tail

heroku logs -app [app name] --tail