Skip to content

Instantly share code, notes, and snippets.

@firestar
Created July 5, 2012 18:31
Show Gist options
  • Save firestar/3055546 to your computer and use it in GitHub Desktop.
Save firestar/3055546 to your computer and use it in GitHub Desktop.
Lines of code in scripts
<?php
$intoVAT = array("/var/path/to/script");
function read_dir($dir, $array = array()){
$dh = opendir($dir);
$files = array();
while (($file = readdir($dh)) !== false) {
$flag = false;
if($file !== '.' && $file !== '..' && is_dir($dir."/".$file)) {
$files[] = $dir."/".$file;
$files = array_merge(read_dir($dir."/".$file),$files);
echo $dir."/".$file."\n";
}
}
return $files;
}
$gt = 0;
$final = array();
foreach($intoVAT as $into){
if(is_dir($into)){
$final[] = $into;
$final = array_merge($final,read_dir($into));
}
}
$fr = array_unique($final);
foreach($fr as $f){
exec("cd ".$f.";wc -l ./*.php",$meow);
if (preg_match('/([0-9]+) total/s', $meow[(count($meow)-1)], $out)) {
echo $out[1].$f."\n";
$gt += $out[1];
}
}
echo "TOTAL: $gt";
@envygeeks
Copy link

skip = ['fuck/', 'you/', 'asshole/']
total = 0

(Dir['**/*.rb'] - skip).each do |file|
  if File.file?(file)
    total += `wc -l #{file}`.gsub(%r!\s{1}#{file}!, '')
  end
end

$stdout.puts total

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