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
| # Rime default settings | |
| # encoding: utf-8 | |
| patch: | |
| schema_list: | |
| - schema: wubi_pinyin | |
| switcher/caption: $ | |
| menu: | |
| page_size: 5 |
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 f(s, n, i) { | |
| if (n == 0) return s + "<br/>"; | |
| else { | |
| var p = (s == "") ? n + "=" : s + "+"; | |
| var m = (s == "") ? n - 1 : n; | |
| var r = ""; | |
| for (var j = i; j <= m; j++) | |
| r += f(p + j, n - j, j); | |
| return r; | |
| } |
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 printDigit(n) { | |
| document.write(n); | |
| } | |
| function printOut(n) { | |
| if (n >= 10) | |
| printOut(parseInt(n / 10)); | |
| printDigit(n % 10); | |
| } |
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 IntCell | |
| { | |
| public: | |
| explicit IntCell(int initialValue = 0) | |
| :storedValue(initialValue) {} | |
| int read() const {return storedValue;} | |
| void write(int x) {storedValue = x;} | |
| private: |
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
| var N = 1000; | |
| var arr = []; | |
| for (var i = 0; i < N; i++) | |
| arr.push(Math.random() * N); | |
| var target = parseInt(N / 2); | |
| function bubbleSort(arr) { | |
| for (var i = 1; i < N; i++) { // do N-1 times | |
| for (var j = 0; j < N - i; j++) { |
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 count1InBin(n){ | |
| if(n<2) | |
| return n&1; | |
| return count1InBin(n>>1)+(n&1); // note: +'s priority is higher than & | |
| } | |
| console.log(count1InBin(0)); // output: 0 | |
| console.log(count1InBin(1)); // output: 1 | |
| console.log(count1InBin(2)); // output: 1 | |
| console.log(count1InBin(3)); // output: 2 |
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 min(a,b) {return a<b&&a||b;} | |
| function max(a,b) {return a>b&&a||b;} |
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
| wget http://pypi.python.org/packages/source/p/pyOpenSSL/pyOpenSSL-0.13.tar.gz && tar zxvf pyOpenSSL-0.13.tar.gz && cd pyOpenSSL-0.13 && sudo python3 setup.py install |
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 maxSubSum(arr) { | |
| var maxSum = 0, thisSum = 0; | |
| for (i = 0; i < arr.length; i++) { | |
| thisSum += arr[i]; | |
| if (thisSum > maxSum) | |
| maxSum = thisSum; | |
| else if (thisSum < 0) | |
| thisSum = 0; | |
| } | |
| return maxSum; |
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.prototype.before = function(func){ | |
| var __self =this; | |
| return function(){ | |
| var ret = func.apply(this, arguments); | |
| if(ret===false){ | |
| return false; | |
| } | |
| __self.apply(this, arguments); | |
| return ret; | |
| } |