Skip to content

Instantly share code, notes, and snippets.

View kevinxh's full-sized avatar
:shipit:

Kevin He kevinxh

:shipit:
  • salesforce
View GitHub Profile
@kevinxh
kevinxh / API.md
Created May 22, 2016 21:17 — forked from iros/API.md
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@kevinxh
kevinxh / git-branches-by-commit-date.sh
Last active March 29, 2019 19:49 — forked from jasonrudolph/git-branches-by-commit-date.sh
List remote Git branches and the last commit date for each branch. Sort by most recent commit date. #git
# Credit http://stackoverflow.com/a/2514279
for branch in `git branch -r | grep -v HEAD`;do echo -e `git show --format="%ci %cr" $branch | head -n 1` \\t$branch; done | sort -r
@kevinxh
kevinxh / docker-cheat-sheet.md
Last active March 29, 2019 19:51
Docker Cheat Sheet #docker
@kevinxh
kevinxh / cache-requests.md
Last active December 10, 2020 22:23
Caching mechanism to avoid duplicate requests #pattern

How to avoid sending duplicate requests?

It is common to see the client side sending duplicate fetch data requests to an API endpoint or desktop page.

To avoid sending duplicate requests, I recommend to implement a caching function that caches HTTP responses.

Example:

    // WARNING: this is sudo code, test before use!
 const promiseCache = {}
@kevinxh
kevinxh / README.md
Last active February 5, 2024 20:01
Hybrid Deployment Support

Sample Auth.js to support hybrid deployment

This gist includes sample code which supports hybrid deployment in PWA Kit retail react app. The major changes are in auth.js where the authentication module supports storing auth tokens as cookies.

If you generated a PWA Kit project prior to v1.5, you need to adopt the changes from this file in your project.

Code diffs are available in the PR: https://github.com/SalesforceCommerceCloud/pwa-kit/pull/429/files

Authentication flow diagram

@kevinxh
kevinxh / README.md
Last active March 19, 2024 17:01
PWA Kit extensibility eject and restore CLI command

What is this tool?

This tool essentially help you "eject" files from the extended projects.

Usage

Eject - copy files from the base template into the overrides folder

@kevinxh
kevinxh / README.md
Created March 25, 2024 21:05
Node.js invalid http header demo

Nodejs invalid http header error

When attempting to set http headers with invalid characters, Nodejs will throw a TypeError.

node:_http_outgoing:628
    throw new ERR_INVALID_CHAR('header content', name);
    ^