This file contains 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 <cassert> | |
#include <condition_variable> | |
#include <iostream> | |
#include <mutex> | |
#include <thread> | |
using namespace std; | |
condition_variable tester; | |
mutex sync0, sync1, a, b, graph_sync; |
This file contains 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 <cmath> | |
#include <iostream> | |
#include <memory> | |
#include <random> | |
using namespace std; | |
#define FLOAT long double | |
struct Point { |
This file contains 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 <cassert> | |
#include <cmath> | |
#include <iostream> | |
#include <vector> | |
#define FLOAT long double | |
#define epsilon 1e-8 | |
using namespace std; |
This file contains 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
/** | |
* This program answers a fundamental question to life: | |
* | |
* Are there three dices A, B and C that satisfies P[A > B], P[B > C], P[C > A] > 5/9? | |
* | |
* It turns out there is. | |
*/ | |
#include <cstdio> |
This file contains 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
#!/bin/bash | |
number=$1 | |
method=$2 | |
ss-tunnel -k test -m $method -l 8387 -L 127.0.0.1:8388 -s 127.0.0.1 -p 8389 & | |
ss_tunnel_pid=$! | |
ss-server -k test -m $method -s 127.0.0.1 -p 8389 & | |
ss_server_pid=$! |
This file contains 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
/** | |
* Detect errors in your device. | |
* | |
* Usage: sudo ./lserrs <page size in bytes> <device name> | |
*/ | |
#include <fcntl.h> | |
#include <unistd.h> | |
#include <iostream> | |
#include <memory> |
This file contains 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 <random> | |
using namespace std; | |
int main() { | |
random_device dev; | |
default_random_engine engine(dev()); | |
uniform_int_distribution<int> dist(0, 99999999); | |
int x, y, z, count = 0; |
This file contains 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
hodor - opendoor | |
hot - cold | |
close - open | |
yes - no | |
loss - gain | |
less - important | |
lose - gain | |
loser - gainer | |
evil - good | |
hate - love |
This file contains 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
sudo apt install apache2 php7.0-dev libapache2-mod-php7.0 php7.0-mbstring php7.0-mcrypt php7.0-xml | |
sudo tee -a /etc/hosts <<- hosts | |
127.0.0.1 zh.localhost | |
127.0.0.1 en.localhost | |
hosts | |
sudo vim /etc/apache2/apache2.conf | |
sudo vim /etc/apache2/sites-available/000-default.conf | |
sudo vim /etc/php/7.0/apache2/php.ini | |
pushd ~/Products/GitHub # or whatever dir you want |
This file contains 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
// followers score = sum((1 + user.followers) / user.following) for user in your followers | |
// We believe a user is more valuable if he/she doesn't follow everyone he/she sees on GitHub. | |
function getFollowersScore(username) { | |
var request = new XMLHttpRequest(); | |
request.open('get', 'https://api.github.com/users/' + username + '/followers', false); | |
request.send(null); | |
var result = 0; | |
var followers = JSON.parse(request.response); | |
var pending = followers.length; |