Last active
August 29, 2023 19:00
-
-
Save sgbaird/0ddeb5b60cc94b99a2fe8d1bb7a80e00 to your computer and use it in GitHub Desktop.
Count the number of lines of code using cloc and Google Colab (https://github.com/AlDanial/cloc). This is useful when you surpass the 500 MB limit of https://codetabs.com/count-loc/count-loc-online.html.
This file contains 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
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"provenance": [], | |
"authorship_tag": "ABX9TyO+XcttCKSBpv5ruiKfx/el", | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "python3", | |
"display_name": "Python 3" | |
}, | |
"language_info": { | |
"name": "python" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/sgbaird/0ddeb5b60cc94b99a2fe8d1bb7a80e00/count-lines-of-code.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "rqQO-xF8wh-A", | |
"outputId": "14a3b898-728f-443e-8586-50da25ba3dc3" | |
}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Reading package lists... Done\n", | |
"Building dependency tree... Done\n", | |
"Reading state information... Done\n", | |
"The following additional packages will be installed:\n", | |
" libalgorithm-diff-perl libalgorithm-diff-xs-perl libb-hooks-endofscope-perl\n", | |
" libb-hooks-op-check-perl libclass-method-modifiers-perl\n", | |
" libclass-xsaccessor-perl libdevel-callchecker-perl\n", | |
" libdynaloader-functions-perl libimport-into-perl\n", | |
" libmodule-implementation-perl libmodule-runtime-perl libmoo-perl\n", | |
" libnamespace-clean-perl libpackage-stash-perl libpackage-stash-xs-perl\n", | |
" libparallel-forkmanager-perl libparams-classify-perl libregexp-common-perl\n", | |
" librole-tiny-perl libsub-exporter-progressive-perl libsub-identify-perl\n", | |
" libsub-name-perl libsub-quote-perl libtry-tiny-perl libvariable-magic-perl\n", | |
"Suggested packages:\n", | |
" libscalar-number-perl\n", | |
"The following NEW packages will be installed:\n", | |
" cloc libalgorithm-diff-perl libalgorithm-diff-xs-perl\n", | |
" libb-hooks-endofscope-perl libb-hooks-op-check-perl\n", | |
" libclass-method-modifiers-perl libclass-xsaccessor-perl\n", | |
" libdevel-callchecker-perl libdynaloader-functions-perl libimport-into-perl\n", | |
" libmodule-implementation-perl libmodule-runtime-perl libmoo-perl\n", | |
" libnamespace-clean-perl libpackage-stash-perl libpackage-stash-xs-perl\n", | |
" libparallel-forkmanager-perl libparams-classify-perl libregexp-common-perl\n", | |
" librole-tiny-perl libsub-exporter-progressive-perl libsub-identify-perl\n", | |
" libsub-name-perl libsub-quote-perl libtry-tiny-perl libvariable-magic-perl\n", | |
"0 upgraded, 26 newly installed, 0 to remove and 16 not upgraded.\n", | |
"Need to get 744 kB of archives.\n", | |
"After this operation, 2,609 kB of additional disk space will be used.\n", | |
"Get:1 http://archive.ubuntu.com/ubuntu jammy/main amd64 libalgorithm-diff-perl all 1.201-1 [41.8 kB]\n", | |
"Get:2 http://archive.ubuntu.com/ubuntu jammy/main amd64 libclass-method-modifiers-perl all 2.13-1 [16.2 kB]\n", | |
"Get:3 http://archive.ubuntu.com/ubuntu jammy/main amd64 libclass-xsaccessor-perl amd64 1.19-3build9 [34.1 kB]\n", | |
"Get:4 http://archive.ubuntu.com/ubuntu jammy/main amd64 libb-hooks-op-check-perl amd64 0.22-1build5 [10.3 kB]\n", | |
"Get:5 http://archive.ubuntu.com/ubuntu jammy/main amd64 libdynaloader-functions-perl all 0.003-1.1 [12.1 kB]\n", | |
"Get:6 http://archive.ubuntu.com/ubuntu jammy/main amd64 libdevel-callchecker-perl amd64 0.008-1ubuntu4 [14.9 kB]\n", | |
"Get:7 http://archive.ubuntu.com/ubuntu jammy/main amd64 libparams-classify-perl amd64 0.015-1build5 [22.0 kB]\n", | |
"Get:8 http://archive.ubuntu.com/ubuntu jammy/main amd64 libmodule-runtime-perl all 0.016-1 [16.2 kB]\n", | |
"Get:9 http://archive.ubuntu.com/ubuntu jammy/main amd64 libimport-into-perl all 1.002005-1 [11.0 kB]\n", | |
"Get:10 http://archive.ubuntu.com/ubuntu jammy/main amd64 librole-tiny-perl all 2.002004-1 [16.3 kB]\n", | |
"Get:11 http://archive.ubuntu.com/ubuntu jammy/main amd64 libsub-quote-perl all 2.006006-1 [19.5 kB]\n", | |
"Get:12 http://archive.ubuntu.com/ubuntu jammy/main amd64 libmoo-perl all 2.005004-3 [48.0 kB]\n", | |
"Get:13 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libparallel-forkmanager-perl all 2.02-1 [27.7 kB]\n", | |
"Get:14 http://archive.ubuntu.com/ubuntu jammy/universe amd64 libregexp-common-perl all 2017060201-1 [168 kB]\n", | |
"Get:15 http://archive.ubuntu.com/ubuntu jammy/universe amd64 cloc all 1.90-1 [106 kB]\n", | |
"Get:16 http://archive.ubuntu.com/ubuntu jammy/main amd64 libalgorithm-diff-xs-perl amd64 0.04-6build3 [11.9 kB]\n", | |
"Get:17 http://archive.ubuntu.com/ubuntu jammy/main amd64 libtry-tiny-perl all 0.31-1 [21.8 kB]\n", | |
"Get:18 http://archive.ubuntu.com/ubuntu jammy/main amd64 libmodule-implementation-perl all 0.09-1.1 [11.6 kB]\n", | |
"Get:19 http://archive.ubuntu.com/ubuntu jammy/main amd64 libsub-exporter-progressive-perl all 0.001013-1 [6,784 B]\n", | |
"Get:20 http://archive.ubuntu.com/ubuntu jammy/main amd64 libvariable-magic-perl amd64 0.62-1build5 [35.9 kB]\n", | |
"Get:21 http://archive.ubuntu.com/ubuntu jammy/main amd64 libb-hooks-endofscope-perl all 0.25-1 [17.8 kB]\n", | |
"Get:22 http://archive.ubuntu.com/ubuntu jammy/main amd64 libpackage-stash-perl all 0.39-1 [19.1 kB]\n", | |
"Get:23 http://archive.ubuntu.com/ubuntu jammy/main amd64 libsub-identify-perl amd64 0.14-1build5 [10.4 kB]\n", | |
"Get:24 http://archive.ubuntu.com/ubuntu jammy/main amd64 libsub-name-perl amd64 0.26-1build3 [11.4 kB]\n", | |
"Get:25 http://archive.ubuntu.com/ubuntu jammy/main amd64 libnamespace-clean-perl all 0.27-1 [13.6 kB]\n", | |
"Get:26 http://archive.ubuntu.com/ubuntu jammy/main amd64 libpackage-stash-xs-perl amd64 0.29-1build5 [19.4 kB]\n", | |
"Fetched 744 kB in 0s (1,643 kB/s)\n", | |
"Selecting previously unselected package libalgorithm-diff-perl.\n", | |
"(Reading database ... 120831 files and directories currently installed.)\n", | |
"Preparing to unpack .../00-libalgorithm-diff-perl_1.201-1_all.deb ...\n", | |
"Unpacking libalgorithm-diff-perl (1.201-1) ...\n", | |
"Selecting previously unselected package libclass-method-modifiers-perl.\n", | |
"Preparing to unpack .../01-libclass-method-modifiers-perl_2.13-1_all.deb ...\n", | |
"Unpacking libclass-method-modifiers-perl (2.13-1) ...\n", | |
"Selecting previously unselected package libclass-xsaccessor-perl.\n", | |
"Preparing to unpack .../02-libclass-xsaccessor-perl_1.19-3build9_amd64.deb ...\n", | |
"Unpacking libclass-xsaccessor-perl (1.19-3build9) ...\n", | |
"Selecting previously unselected package libb-hooks-op-check-perl.\n", | |
"Preparing to unpack .../03-libb-hooks-op-check-perl_0.22-1build5_amd64.deb ...\n", | |
"Unpacking libb-hooks-op-check-perl (0.22-1build5) ...\n", | |
"Selecting previously unselected package libdynaloader-functions-perl.\n", | |
"Preparing to unpack .../04-libdynaloader-functions-perl_0.003-1.1_all.deb ...\n", | |
"Unpacking libdynaloader-functions-perl (0.003-1.1) ...\n", | |
"Selecting previously unselected package libdevel-callchecker-perl.\n", | |
"Preparing to unpack .../05-libdevel-callchecker-perl_0.008-1ubuntu4_amd64.deb ...\n", | |
"Unpacking libdevel-callchecker-perl (0.008-1ubuntu4) ...\n", | |
"Selecting previously unselected package libparams-classify-perl.\n", | |
"Preparing to unpack .../06-libparams-classify-perl_0.015-1build5_amd64.deb ...\n", | |
"Unpacking libparams-classify-perl (0.015-1build5) ...\n", | |
"Selecting previously unselected package libmodule-runtime-perl.\n", | |
"Preparing to unpack .../07-libmodule-runtime-perl_0.016-1_all.deb ...\n", | |
"Unpacking libmodule-runtime-perl (0.016-1) ...\n", | |
"Selecting previously unselected package libimport-into-perl.\n", | |
"Preparing to unpack .../08-libimport-into-perl_1.002005-1_all.deb ...\n", | |
"Unpacking libimport-into-perl (1.002005-1) ...\n", | |
"Selecting previously unselected package librole-tiny-perl.\n", | |
"Preparing to unpack .../09-librole-tiny-perl_2.002004-1_all.deb ...\n", | |
"Unpacking librole-tiny-perl (2.002004-1) ...\n", | |
"Selecting previously unselected package libsub-quote-perl.\n", | |
"Preparing to unpack .../10-libsub-quote-perl_2.006006-1_all.deb ...\n", | |
"Unpacking libsub-quote-perl (2.006006-1) ...\n", | |
"Selecting previously unselected package libmoo-perl.\n", | |
"Preparing to unpack .../11-libmoo-perl_2.005004-3_all.deb ...\n", | |
"Unpacking libmoo-perl (2.005004-3) ...\n", | |
"Selecting previously unselected package libparallel-forkmanager-perl.\n", | |
"Preparing to unpack .../12-libparallel-forkmanager-perl_2.02-1_all.deb ...\n", | |
"Unpacking libparallel-forkmanager-perl (2.02-1) ...\n", | |
"Selecting previously unselected package libregexp-common-perl.\n", | |
"Preparing to unpack .../13-libregexp-common-perl_2017060201-1_all.deb ...\n", | |
"Unpacking libregexp-common-perl (2017060201-1) ...\n", | |
"Selecting previously unselected package cloc.\n", | |
"Preparing to unpack .../14-cloc_1.90-1_all.deb ...\n", | |
"Unpacking cloc (1.90-1) ...\n", | |
"Selecting previously unselected package libalgorithm-diff-xs-perl.\n", | |
"Preparing to unpack .../15-libalgorithm-diff-xs-perl_0.04-6build3_amd64.deb ...\n", | |
"Unpacking libalgorithm-diff-xs-perl (0.04-6build3) ...\n", | |
"Selecting previously unselected package libtry-tiny-perl.\n", | |
"Preparing to unpack .../16-libtry-tiny-perl_0.31-1_all.deb ...\n", | |
"Unpacking libtry-tiny-perl (0.31-1) ...\n", | |
"Selecting previously unselected package libmodule-implementation-perl.\n", | |
"Preparing to unpack .../17-libmodule-implementation-perl_0.09-1.1_all.deb ...\n", | |
"Unpacking libmodule-implementation-perl (0.09-1.1) ...\n", | |
"Selecting previously unselected package libsub-exporter-progressive-perl.\n", | |
"Preparing to unpack .../18-libsub-exporter-progressive-perl_0.001013-1_all.deb ...\n", | |
"Unpacking libsub-exporter-progressive-perl (0.001013-1) ...\n", | |
"Selecting previously unselected package libvariable-magic-perl.\n", | |
"Preparing to unpack .../19-libvariable-magic-perl_0.62-1build5_amd64.deb ...\n", | |
"Unpacking libvariable-magic-perl (0.62-1build5) ...\n", | |
"Selecting previously unselected package libb-hooks-endofscope-perl.\n", | |
"Preparing to unpack .../20-libb-hooks-endofscope-perl_0.25-1_all.deb ...\n", | |
"Unpacking libb-hooks-endofscope-perl (0.25-1) ...\n", | |
"Selecting previously unselected package libpackage-stash-perl.\n", | |
"Preparing to unpack .../21-libpackage-stash-perl_0.39-1_all.deb ...\n", | |
"Unpacking libpackage-stash-perl (0.39-1) ...\n", | |
"Selecting previously unselected package libsub-identify-perl.\n", | |
"Preparing to unpack .../22-libsub-identify-perl_0.14-1build5_amd64.deb ...\n", | |
"Unpacking libsub-identify-perl (0.14-1build5) ...\n", | |
"Selecting previously unselected package libsub-name-perl.\n", | |
"Preparing to unpack .../23-libsub-name-perl_0.26-1build3_amd64.deb ...\n", | |
"Unpacking libsub-name-perl (0.26-1build3) ...\n", | |
"Selecting previously unselected package libnamespace-clean-perl.\n", | |
"Preparing to unpack .../24-libnamespace-clean-perl_0.27-1_all.deb ...\n", | |
"Unpacking libnamespace-clean-perl (0.27-1) ...\n", | |
"Selecting previously unselected package libpackage-stash-xs-perl.\n", | |
"Preparing to unpack .../25-libpackage-stash-xs-perl_0.29-1build5_amd64.deb ...\n", | |
"Unpacking libpackage-stash-xs-perl (0.29-1build5) ...\n", | |
"Setting up libdynaloader-functions-perl (0.003-1.1) ...\n", | |
"Setting up libclass-method-modifiers-perl (2.13-1) ...\n", | |
"Setting up libalgorithm-diff-perl (1.201-1) ...\n", | |
"Setting up libsub-identify-perl (0.14-1build5) ...\n", | |
"Setting up libtry-tiny-perl (0.31-1) ...\n", | |
"Setting up libregexp-common-perl (2017060201-1) ...\n", | |
"Setting up libpackage-stash-xs-perl (0.29-1build5) ...\n", | |
"Setting up libvariable-magic-perl (0.62-1build5) ...\n", | |
"Setting up libb-hooks-op-check-perl (0.22-1build5) ...\n", | |
"Setting up libsub-exporter-progressive-perl (0.001013-1) ...\n", | |
"Setting up libsub-name-perl (0.26-1build3) ...\n", | |
"Setting up librole-tiny-perl (2.002004-1) ...\n", | |
"Setting up libsub-quote-perl (2.006006-1) ...\n", | |
"Setting up libclass-xsaccessor-perl (1.19-3build9) ...\n", | |
"Setting up libalgorithm-diff-xs-perl (0.04-6build3) ...\n", | |
"Setting up libdevel-callchecker-perl (0.008-1ubuntu4) ...\n", | |
"Setting up libparams-classify-perl (0.015-1build5) ...\n", | |
"Setting up libmodule-runtime-perl (0.016-1) ...\n", | |
"Setting up libmodule-implementation-perl (0.09-1.1) ...\n", | |
"Setting up libpackage-stash-perl (0.39-1) ...\n", | |
"Setting up libimport-into-perl (1.002005-1) ...\n", | |
"Setting up libmoo-perl (2.005004-3) ...\n", | |
"Setting up libparallel-forkmanager-perl (2.02-1) ...\n", | |
"Setting up libb-hooks-endofscope-perl (0.25-1) ...\n", | |
"Setting up cloc (1.90-1) ...\n", | |
"Setting up libnamespace-clean-perl (0.27-1) ...\n", | |
"Processing triggers for man-db (2.10.2-1) ...\n" | |
] | |
} | |
], | |
"source": [ | |
"!apt install cloc" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!git clone https://github.com/facebook/Ax.git" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "CkPHX-Qowkdc", | |
"outputId": "d3fdd588-8cca-4f80-cc30-ba1687463ef1" | |
}, | |
"execution_count": 2, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Cloning into 'Ax'...\n", | |
"remote: Enumerating objects: 33830, done.\u001b[K\n", | |
"remote: Counting objects: 100% (4803/4803), done.\u001b[K\n", | |
"remote: Compressing objects: 100% (549/549), done.\u001b[K\n", | |
"remote: Total 33830 (delta 4624), reused 4299 (delta 4254), pack-reused 29027\u001b[K\n", | |
"Receiving objects: 100% (33830/33830), 541.42 MiB | 22.22 MiB/s, done.\n", | |
"Resolving deltas: 100% (27340/27340), done.\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"%cd /content/Ax/ax" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "9LEeWBaaw8zW", | |
"outputId": "6e3244c0-da3c-4132-c6ec-830541d96d43" | |
}, | |
"execution_count": 10, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"/content/Ax/ax\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!cloc ." | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "P4z-hVe2xJqI", | |
"outputId": "3fee13b5-3f4b-4df4-e742-d1e2fa9d75e5" | |
}, | |
"execution_count": 11, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
" 100 files\r 200 files\r 300 files\r 400 files\r 500 files\r 517 text files.\n", | |
" 467 unique files. \n", | |
" 51 files ignored.\n", | |
"\n", | |
"github.com/AlDanial/cloc v 1.90 T=1.47 s (318.7 files/s, 86478.2 lines/s)\n", | |
"-------------------------------------------------------------------------------\n", | |
"Language files blank comment code\n", | |
"-------------------------------------------------------------------------------\n", | |
"Python 456 13527 21525 91032\n", | |
"JavaScript 6 26 43 222\n", | |
"CSS 2 42 15 215\n", | |
"HTML 3 0 9 62\n", | |
"-------------------------------------------------------------------------------\n", | |
"SUM: 467 13595 21592 91531\n", | |
"-------------------------------------------------------------------------------\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [], | |
"metadata": { | |
"id": "5TaNZZktxRcq" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment