Skip to content

Instantly share code, notes, and snippets.

View lxynox's full-sized avatar
🌴
On vacation

⦇⦀∙ˇ∎ˇ∙⦀⦈ lxynox

🌴
On vacation
View GitHub Profile
@lxynox
lxynox / keymaps.json
Created November 13, 2018 18:26
Hyper term keymaps (mac)
{
"window:devtools": "command+alt+i",
"window:reload": "command+r",
"window:reloadFull": "command+shift+r",
"window:preferences": "command+,",
"zoom:reset": "command+0",
"zoom:in": "command+plus",
"zoom:out": "command+-",
"window:new": "command+n",
"window:minimize": "command+m",
@lxynox
lxynox / ascii_octocat.md
Last active December 20, 2021 00:17
Query ASCII Art version octocat using github api

How about an ascii art version Octocat?

This can simply be achieved by the github api(https://api.github.com/octocat?s={query_string_value}), replace the {query_string_value} with the words you want the octocat to say.

As the browser trims empty space for display, the pattern might not render properly, i found 2 ways to preview:

  1. web inspector

If using Chrome, open Chrome Dev Tool and inspect the HTML elements, it's wrapped in a pair of <pre></pre> tag.

@lxynox
lxynox / mobx-state-tree.md
Last active May 29, 2020 04:10
Front-end (react) state management solutions

mobx-state-tree is a state container that combines the simplicity and ease of mutable data with the traceability of immutable data and the reactiveness and performance of observable data.

How???

feature/
  state/
 - index.js
@lxynox
lxynox / babel-webpack.md
Created March 26, 2020 07:56 — forked from ncochard/babel-webpack.md
The correct way to compile ES6 using babel...

When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:

  1. Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
  2. Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
  3. Is it going to be used as a dependency to a browser application (always bundled)?.
  • In cases 2) and 3) you want to allow for tree shaking.
  • In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
  • In case 3) you also want to benefit from the native support of "ES6" from your browser.
@lxynox
lxynox / node_modules.md
Last active November 19, 2019 15:13
Things around node_modules

Dependency

Peer Dependency

What we need is a way of expressing these "dependencies" between plugins and their host package. Some way of saying, "I only work when plugged in to version 1.2.x of my host package, so if you install me, be sure that it's alongside a compatible host." We call this relationship a peer dependency.

Problem Solution
@lxynox
lxynox / test-local-module.md
Last active November 19, 2019 14:45
Various ways to test a local module before publishing

Always starts from changing node_modules/ directly, for more complex use cases

🔰🔰🔰

npm link

/path/to/lib $ npm link
/path/to/app $ npm link lib
@lxynox
lxynox / sequencing-promises.md
Created September 24, 2019 03:03
Resolve promises one after another (i.e. in sequence)

asycn/await

async function readFiles(files) {
  for(const file of files) {
    await readFile(file);
  }
};

yield

@lxynox
lxynox / simple-router.md
Last active September 12, 2019 08:09
simple react router

Top level Components handles client-side navigation state (HTML5 history api) transition

History API (State - source of truth)

Link (Dispatcher)

class Link extends React.PureComponent {
  static propTypes = {
    to: PropTypes.string,
@lxynox
lxynox / createStore.md
Last active September 12, 2019 08:08
simple redux
const createStore = (rootReducer) => {
  let state
  let listeners

  const getState = (state) => state

  const dispatch = (action) => {
    state = rootReducer(action, state)
 listeners.forEach(l =&gt; l())
@lxynox
lxynox / hackathon-AD.md
Last active September 12, 2019 08:03 — forked from lxyad/intro.md
pwa

Features

  • Add to home screen
  • Install banner
  • Offline support
  • App shell
  • Push notifications?
  • Background sync?
  • Server side rendering (SEO + improve First Meaningful Paint(FMP))