Use this GIST to copy the protocol on your remix, play with Todo.sol to build better HSTP protocol.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
| <title>Auto Complete</title> | |
| <style> | |
| #container { | |
| width: 200px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Node { | |
| constructor(char) { | |
| this.char = char; | |
| this.children = new Map(); // It's limited by 26 chars, hashmap. | |
| this.isEndWord = false; | |
| } | |
| } | |
| class Trie { | |
| constructor() { | |
| this.root = new Node(""); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function throttle (callback, limit) { | |
| var waiting = false; // Initially, we're not waiting | |
| return function () { // We return a throttled function | |
| if (!waiting) { // If we're not waiting | |
| callback.apply(this, arguments); // Execute users function | |
| waiting = true; // Prevent future invocations | |
| setTimeout(function () { // After a period of time | |
| waiting = false; // And allow future invocations | |
| }, limit); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>Star component</title> | |
| <style> | |
| .star-wrapper { | |
| display: flex; | |
| flex-direction: row-reverse; | |
| justify-content: flex-end; | |
| } | |
| .star { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <title>Accordion menu - Simple</title> | |
| <style> | |
| .accordion-wrapper { | |
| display: flex; | |
| align-items: center; | |
| flex-direction: column; | |
| } | |
| .accordion { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const assert = require("assert"); | |
| function generateTrie(array) { | |
| const trie = { "": {} }; | |
| for (const word of array) { | |
| let currentNode = trie[""]; | |
| Array.from(word).forEach((char) => { | |
| if (!currentNode[char]) { | |
| currentNode[char] = {}; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function generate(...input) { | |
| const tree = {'': {}}; | |
| for (const text of input) { | |
| let currentNode = tree['']; | |
| Array.from(text).forEach(char => { | |
| if (!currentNode[char]) { | |
| currentNode[char] = {}; | |
| } | |
| currentNode = currentNode[char] | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function debounce(func, wait, immediate) { | |
| let timeout = null; | |
| return function () { | |
| let context = this; | |
| let args = arguments; | |
| const later = function () { | |
| timeout = null; | |
| if (!immediate) func.apply(context, args); | |
| } | |
| const callNow = immediate && !timeout; |