Created
June 26, 2015 17:41
-
-
Save felipecwb/64a29aa866169833701a to your computer and use it in GitHub Desktop.
Code Like a Boss
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
| #!/usr/bin/env php | |
| <?php | |
| if(!isset($argv[1])) { | |
| die("\nPlease, run: codelikeaboss /your/files/dir\n"); | |
| } | |
| system("clear"); | |
| $filetypes = array("php", "rb", "py", "c", "cpp", "java", "txt", "asp", "html", "css", "js", "ini", "md"); | |
| $dir = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($argv[1])); | |
| foreach($dir as $d) { | |
| if (! $d->isFile()) { | |
| continue; | |
| } | |
| $finfo = pathinfo($d->getPathName()); | |
| $finfo['extension'] = isset($finfo['extension']) ? $finfo['extension'] : false; | |
| if(! in_array($finfo['extension'], $filetypes)) { | |
| continue; | |
| } | |
| $f = file($d->getPathName()); | |
| if(! is_array($f)) { | |
| continue; | |
| } | |
| echo "\n\n--- " . $d->getPathName() . PHP_EOL . PHP_EOL; | |
| foreach($f as $line) { | |
| for($i = 0; $i < strlen($line); $i++) { | |
| echo "{$line[$i]}"; | |
| usleep(99990); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment