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 { | |
| box-sizing: border-box; | |
| } | |
| *, *:before, *:after { | |
| box-sizing: inherit; | |
| } |
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
| *, *:before, *:after { | |
| -webkit-box-sizing: border-box; | |
| -moz-box-sizing: border-box; | |
| box-sizing: border-box; | |
| } |
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 add (a, b) { | |
| return a + b | |
| } | |
| foo = [10, 20, 30, 40] | |
| bar = foo.map(add.bind(null, 5)) | |
| console.log(bar) |
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
| /** | |
| * Use Proxy to implement observable | |
| */ | |
| function observable (obj, onchange) { | |
| return new Proxy(obj, { | |
| set (target, key, value) { | |
| Reflect.set(target, key, value) | |
| onchange(key, value) | |
| }, | |
| delete (target, key) { |
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> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>Building a router</title> | |
| <script> | |
| // Put John's template engine code here... | |
| (function () { | |
| // A hash to store our routes: |
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 adder = new Function('a', 'b', 'return a + b') | |
| adder(2, 3) |
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
| { | |
| "configurations": [ | |
| { | |
| "name": "Mac", | |
| "includePath": [ | |
| "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1", | |
| "/usr/local/include", | |
| "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include", | |
| "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include", | |
| "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include", |
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
| /** | |
| * 参考 https://github.com/janl/mustache.js/blob/b283da5c8c26dbf78c357a1f67bfed26d18f5e32/mustache.js#L60 | |
| */ | |
| var entityMap = { | |
| '&': '&', | |
| '<': '<', | |
| '>': '>', | |
| '"': '"', | |
| "'": ''', | |
| '/': '/', |
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
| str = 'hello {name}, say {msg}. {name} is a handsome boy, {age}!' | |
| reg = /{([^{}]+)}/g | |
| data = { | |
| name: 'eason', | |
| msg: 'hi' | |
| } | |
| str.replace(reg, function (_, key) { | |
| return data[key] || `{${key}}` | |
| }) | |
| // "hello eason, say hi. eason is a handsome boy, {age}!" |
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
| if [ -f .bashrc ] ; then | |
| echo "bashrc exists" | |
| else | |
| echo "bashrc does not exist" | |
| fi | |
| if [[ -r .bashrc ]] | |
| then | |
| echo ".bashrc exists and have permission granted." | |
| fi |