Skip to content

Instantly share code, notes, and snippets.

View dwelle's full-sized avatar

David Luzar dwelle

View GitHub Profile
@dwelle
dwelle / test.excalidraw
Created January 5, 2021 21:15
Excalidraw test
{
"type": "excalidraw",
"version": 2,
"source": "https://excalidraw.com",
"elements": [
{
"id": "hz1wSxPkfpxf1xd7LPSoV",
"type": "rectangle",
"x": 785,
"y": 195,
@dwelle
dwelle / useStableCallback.md
Last active October 10, 2020 08:59
Dependency-less stable callback in React hooks

Say goodbye to code shuffling to satisfy useCallback's dependencies.

Simple variant:

export const useStableCallback = (userFn) => {
  const userFnRef = useRef();
  userFnRef.current = userFn;
  const wrapperFnRef = useRef();
  
@dwelle
dwelle / pr_fetch_push.md
Last active March 22, 2020 13:28
Fetching/pushing to PRs from forked repositories

Boomarklets for fetching/pushing to PRs from forked repositories. Click on them when viewing a PR to copy to clipboard a git command.

Bookmarklets

Copy each of the codeblocks to separate bookmarks as urls:

  • fetch:

    javascript:if(location.href.includes("github.com")&&location.href.includes("/pull"))try{const e=document.querySelector(".gh-header-meta .TableObject-item--primary"),t=e.querySelector(".commit-ref:not(.head-ref) a[href]"),c=e.querySelector(".commit-ref.head-ref a[href]"),r=t.href,o=c.href,[,i,h="master"]=o.match(/^(.*?)\/tree\/(.+).*$/)||o.match(/^(.*?github.com\/.*?)$/);navigator.clipboard.writeText(o.includes(r)?`git checkout master && git pull && git checkout ${h}`:`git branch -d FETCH_HEAD; git fetch ${i} ${h} && git checkout FETCH_HEAD`)}catch(e){console.log(e)}