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 / Hoax.md
Created November 24, 2016 22:56
Annoying 4/6 digits confirm code😡

Micro service sending someone spam messages/emails

  1. Register acct where phone/email confirmation is req.
  2. Loop it N times😈
@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.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/1.0.16/vue.js"></script>
<script src="https://fb.me/react-15.1.0.js"></script>
@lxynox
lxynox / lexical-scope-in-js.md
Created March 12, 2017 19:48
test JS lexical scope (`fat arrow` vs `function scope`)

Definition

Lexical Scoping defines how variable names are resolved in nested functions: inner functions contain the scope of parent functions even if the parent function has returned.

test function:

function testScope () {
  'use strict'
  console.log('outer [scope]', this)
  
 return function () {
@lxynox
lxynox / emitter.md
Last active June 22, 2019 08:56
tiny event emitter

Definition

'use strict'

function createEmitter() {
  let evtHandlersMap = {}
  
  // @evt [String] event name
 // @handler [Function] event handlers
@lxynox
lxynox / use-system-clipboard-with-caution.md
Last active April 18, 2017 01:42
Caveats about the System Clipboard

System Clipboard

What's System Clipboard? Wiki

The clipboard is a software facility used for short-term data storage and/or data transfer between documents or applications, via copy and paste operations.

It is most commonly a part of a GUI environment and is usually implemented as an anonymous, temporary data buffer, sometimes called the paste buffer, that can be accessed from most or all programs within the environment via defined programming interfaces. A typical application accesses clipboard functionality by mapping user input (keybindings, menu selections, etc.) to these interfaces.

Use Cases & Problems

@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 / 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 / client-routing-simplified.md
Last active June 22, 2019 08:52
Simplified client-side router (React)

Navigation source of truth (Browser History)

const createHistory = () => {
  const { history } = window
  const listeners = []
  
  const push = (url, state = {}) => {
    history.pushState(state, null, url)
    listeners.forEach(l => l())
  }
@lxynox
lxynox / gist:bf934a7234f0a8e9a6fa876977450789
Created April 16, 2018 01:46 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue: