Skip to content

Instantly share code, notes, and snippets.

View nhducit's full-sized avatar
🚀

nhducit nhducit

🚀
View GitHub Profile
@nhducit
nhducit / Javascript Natural Sort Algorithm With Unicode Support
Last active January 20, 2022 04:06
Javascript Natural Sort Algorithm With Unicode Support
/*
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
* Reference: http://www.overset.com/2008/09/01/javascript-natural-sort-algorithm/
*/
function naturalSort (a, b) {
var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
sre = /(^[ ]*|[ ]*$)/g,
dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
hre = /^0x[0-9a-f]+$/i,
@nhducit
nhducit / machine.js
Last active October 4, 2021 13:59
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@nhducit
nhducit / machine.js
Created April 21, 2020 11:03
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@nhducit
nhducit / machine.js
Created April 21, 2020 06:23
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@nhducit
nhducit / machine.js
Last active March 31, 2020 17:00
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@nhducit
nhducit / machine.js
Created January 4, 2020 15:54
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@nhducit
nhducit / machine.js
Created December 31, 2019 09:10
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
.monaco-shell {
font-family: 'Operator Mono', 'Fira code', 'Inconsolata', monospace;
letter-spacing: 0.5px;
}
.vs-dark .monaco-panel-view .panel > .panel-header > .title {
font-weight: normal;
letter-spacing: 1px;
}
.vs-dark .monaco-workbench > .part.titlebar > .window-title {
color: #fafafa;
@nhducit
nhducit / rebase-latest-master.sh
Last active May 29, 2018 04:03
rebase latest master for lazy people
#!/usr/bin/env bash
cd <projectDir>
currentBranch=$(git rev-parse --abbrev-ref HEAD)
git checkout master
git pull
git checkout $currentBranch
git rebase master
import Reconciler from 'react-reconciler'
import omit from 'lodash/omit'
import capitalize from 'lodash/capitalize'
import { actions as elementActions } from './store/elements'
import * as Elements from './elements'
const roots = new Map()
const emptyObject = {}
const Renderer = Reconciler({