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
@echo off | |
for /r %%f in (*.jpg) do path\to\ffmpeg -i "%%~pf%%~nf.jpg" -pix_fmt monob "%%~pf%%~nf.png" | |
pause |
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
/** | |
* nand-nor-minimizer by Mygod. | |
* | |
* Test samples: | |
* 1000000000000000 NOR(A, B, C, D) | |
* 1111111111111110 NAND(A, B, C, D) | |
* 0000000000001110 | |
* 1110111011101111 | |
* 0110011011100000 My stupid assignment | |
* 0010011101110100 A random test sample |
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
/** | |
* Chopsticks game with leftovers rule solver. | |
* @author Mygod | |
*/ | |
// Here's a set of rules you can customize: | |
#define RULE_SPLITS | |
//#define RULE_SUICIDAL | |
//#define RULE_TRANSFER |
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; |
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
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
#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
/** | |
* 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
#!/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
/** | |
* 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> |