Skip to content

Instantly share code, notes, and snippets.

View alex-petrenko's full-sized avatar
🏎️
Focusing

Aleksei Petrenko alex-petrenko

🏎️
Focusing
View GitHub Profile
@kelvinn
kelvinn / gist:512f72bf1015047af945
Created June 6, 2014 13:01
Recursively Change Line Endings (Windows)
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
)
@thirdwing
thirdwing / memory_check.cpp
Created August 16, 2014 19:57
C++ code to print out runtime memory usage
#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
# 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.)
@Miffyli
Miffyli / assign-credits.py
Last active September 16, 2022 17:28
A very useful script for making sure everyone is credited accordingly
# 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.