Skip to content

Instantly share code, notes, and snippets.

@picasso250
Last active November 8, 2017 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save picasso250/10e024caf8e0fa1bde70 to your computer and use it in GitHub Desktop.
Save picasso250/10e024caf8e0fa1bde70 to your computer and use it in GitHub Desktop.
fast cygwin mirror
<?php
foreach (file('http://cygwin.com/mirrors.lst') as $line) {
echo $line;
if (preg_match('%^\w+://([\w.-]+)/%', $line, $matches)) {
$host = $matches[1];
if (!isset($table[$host])) {
$output = shell_exec("ping $matches[1]");
echo $output;
if (preg_match('/(\d+)ms/', $output, $matches)) {
$table[$host] = $matches[1];
error_log("$host\t$matches[1]\n",3,"mirrors_speed.log");
}
}
}
}
asort($table);
print_r($table);
@picasso250
Copy link
Author

mirrors.ustc.edu.cn 56
ftp.kaist.ac.kr 94

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment