Skip to content

Instantly share code, notes, and snippets.

@felipecwb
Created June 26, 2015 17:41
Show Gist options
  • Save felipecwb/64a29aa866169833701a to your computer and use it in GitHub Desktop.
Save felipecwb/64a29aa866169833701a to your computer and use it in GitHub Desktop.
Code Like a Boss
#!/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