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
# A very useful script for giving credit where it is due: by replacing (most) variable names by the authors who wrote them. | |
# Requirements: pip install gitpython | |
# Usage: python3 assign-credits.py <input_file> <output_file> | |
# Example: python3 assign-credits.py ./src/main.py ./src/main-credited.py | |
# NOTE that this is an awful idea with an awful implementation. The "generated" code likely does not work | |
# (e.g. typing stuff is skipped, class attribute names are replaced). The "author" is decided by the current HEAD of git repo, and whoever | |
# defines the variable first will get the credits (hahaa dunno if even this is right). | |
# It is getting late and I am tired of typing so I will let Github Copilot write something for me. |
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
# expensive way to compute factorial of n | |
def factorial(n): | |
def f(x): | |
return tf.pow(x, n) | |
for i in range(n): | |
f = tfe.gradients_function(f) | |
return f(1.) |
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
#include <iostream> | |
#include <fstream> | |
#include <unistd.h> | |
void process_mem_usage(double& vm_usage, double& resident_set) | |
{ | |
vm_usage = 0.0; | |
resident_set = 0.0; | |
// the two fields we want |
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
REM On Unix you would do this: find ./ -type f -exec dos2unix {} \; | |
REM After installing dos2unix.exe in Windows, you can create a small bat script with the below in it to | |
REM recursively change the line endings. Careful if you have any hidden directories (e.g. .git) | |
for /f "tokens=* delims=" %%a in ('dir "C:\Users\username\path\to\directory" /s /b') do ( | |
"C:\Program Files\unix2dos.exe" %%a | |
) |