Skip to content

Instantly share code, notes, and snippets.

View hackerwins's full-sized avatar
🏠
Working from home

Youngteac Hong hackerwins

🏠
Working from home
View GitHub Profile
it.only('can remove element by ID in array', function() {
const doc = Document.create('test-col', 'test-doc');
assert.equal('{}', doc.toSortedJSON());
let toDelete;
doc.update((root) => {
root['list'] = [];
root['list'].push(1);
root['list'].push(2);
toDelete = root['list'].push(3);
@hackerwins
hackerwins / SplayTree.ts
Last active October 5, 2018 00:04
SplayTree
/**
* SplayTree is weighted binary search tree which is based on SplayTree.
* - https://en.wikipedia.org/wiki/Splay_tree
*
* Original paper on SplayTree:
* - https://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf
*/
export abstract class SplayNode<V> {
protected value: V;
@hackerwins
hackerwins / SortedMap.ts
Created June 26, 2018 01:37
SortedMap using LLRB Tree.
/**
* Implementation of an SortedMap using Left-leaning Red-Black Tree
*
* Original paper on Left-leaning Red-Black Trees:
* - http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf
*
* Invariant 1: No red node has a red child
* Invariant 2: Every leaf path has the same number of black nodes
* Invariant 3: Only the left child can be red (left leaning)
*/
@hackerwins
hackerwins / gist:c7770ecf11957bd9c2e3
Created July 1, 2014 12:53
summernote `onCreateLink` options.
$('.summernote').summernote({
/**
* manipulate link address when user create link
* @param {String} url
* @return {String}
*/
onCreateLink: function (url) {
if (url.indexOf('http://') !== 0) {
url = 'http://' + url;
}