gem install rubocop
rubocop --version
rubocop <file.rb> --autocorrect
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
| #!/usr/bin/env bash | |
| WORKSPACE=$HOME/Exercism/ruby | |
| TRACK=ruby | |
| EXTENSION=rb | |
| cd "$WORKSPACE" || exit | |
| # Get exercise name | |
| if [ -n "$1" ]; then | |
| name="$1" |
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
| // Origin from Basecamp app.hey.com | |
| // refs: https://app.hey.com/assets/helpers/current_helpers-69434f7688aaf68b68226df19cd29426713fdcad.js | |
| // refs: https://github.com/marcoroth/current.js | |
| /** | |
| * On-demand JavaScript objects from "current" HTML <meta> elements | |
| * | |
| * @example | |
| * ```html | |
| * <meta name="current-identity-id" content="123"> |
从 ES6 版本被重命名为 ES2015 开始,后续的版本开始按照 release 的年份来命名。
| Old Edition | New Edition |
|---|
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 dedent(str) { | |
| str = str.replace(/\r?\n/g, '\n') | |
| let arr = str.match(/^[ \t]*(?=\S)/gm) | |
| let i = 0, | |
| min = 1 / 0, | |
| len = (arr || []).length | |
| for (; i < len; i++) min = Math.min(min, arr[i].length) | |
| return len && min | |
| ? str.replace(new RegExp(`^[ \\t]{${min}}`, 'gm'), '') | |
| : str |
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
| <div id="app"></div> | |
| <style> | |
| .red { | |
| color: red; | |
| } | |
| </style> | |
| <script> | |
| function h(tag, props, children) { |
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
| /** | |
| * Translate number to chinese word | |
| * @param num number | |
| */ | |
| const digits = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九'] | |
| const units = ['', '十', '百', '千', '万', '亿'] | |
| const point = '点' |
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
| /** | |
| * Javascript implementation of Java’s String.hashCode() method | |
| * refs: https://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method | |
| * refs: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#hashCode-- | |
| * | |
| * Returns a hash code for a string. | |
| * @param str string | |
| * @return number | |
| */ | |
| function hash(str) { |
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
| # Install main function | |
| install() { | |
| # variables | |
| shadowsocks_passwd="pwd" | |
| shadowsocks_method="aes-256-cfb" | |
| shadowsocks_port="9001" | |
| fast_open="true" | |
| # config | |
| cat > ~/shadowsocks.json<<-EOF |