Saturday, August 27, 2016

Everything I learned about linux in the last whosit, 1472336806

I use awk a lot. Like every day. I don't know much about it, how to use it, etc. I just know how to set the Field Seperator, which in my head I always called delimiter. Which is with the -F was confusing to me. So I guess that's what I used to know, that and fields. But I had to bite the bullet and write my first, real awk script. It's pretty bad you guys:

BEGIN {
        count=0;
        FS = ":";
        total[count] = "";
        lang[count] = "";
        final = 0;
}
{
        clang=$1;
        amount=$2;
        #print lang[count];
        if (clang == lang[count] || lang[count]=="") {
           lang[count] = clang;
           total[count] += amount;
           final +=amount;
                #print final, lang[count];
        }
        else {
         
         count++;
         lang[count] = clang;
         total[count] = amount;        
         final+=amount;
            }
        
        #print clang, total[count];

}
END {
        print "Total LoC: " final;
        for(x in lang){
            percent = (total[x]/final)*100;
            print lang[x], total[x], percent "%";
            }
        #print "Total Amount = $";
}
' file
So all of this is to find your total lines of code and what kind of code, on github by cycling through a cleaned up file of your languages. Now I have a lot of one liners I put in the readme.md, to clean up the stuff I grabbed from github, but let's be honest this project is a mess. I didn't really plan to get this deep into github bullshit today, but I did. The lack of planning shows. But if you want to check the mess out it's all posted on https://github.com/bsdpunk/github-lang So how did my totals come out... Well if you remove the forks and you take out the HTML and CSS:
Total LoC: 394684
AppleScript 696 0.176344%
Go 6761 1.71302%
JavaScript 8320 2.10802%
Perl 23081 5.84797%
PHP 20528 5.20112%
Python 332131 84.1511%
R 1805 0.457328%
Shell 1362 0.345086%
Not bad for all my public/open stuff I guess. Maybe it is, I don't know. I'm going to try to post something about PowerShell, and Linux, and Microsoft, and Opensource, soon, maybe. As like an opinion /slash/ neat tricks with PowerShell.

No comments: