Skip to content

Instantly share code, notes, and snippets.

@nielsrolf
nielsrolf / postgres_setup_django.txt
Last active March 8, 2019 20:17
Install postgres and postGIS on os x and set it up for a (django) app
# DB Setup
# Install postgres
brew install postgres
# Make it start automatically
pg_ctl -D /usr/local/var/postgres start && brew services start postgresql
# start PSQL Shell as admin to create the db user
psql postgres
@nielsrolf
nielsrolf / mandelbrot.ipynb
Created June 15, 2019 09:51
Mandelbrotset
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nielsrolf
nielsrolf / fill_df_with_function_results.md
Last active March 3, 2020 16:08
Given a dataframe with input values for a function, fill it with the function results - e.g. for model selection or other jobs that run long and may fail in between

Fill a DataFrame with function results

For model selection or simulations, it is often needed to collect results of the same functions for many different input parameters. This can be time consuming if the job fails from time to time - always restarting it and only computing the combinations that have not yet been computed. As a helper, you can use this method.

def fill_df_with_function_results(df, kwargs, results, function, save_as, save_errors_as=None):
    """Function to fill up a dataframe with results
    and save intermediate results.
    Assume you have a function that takes some key word arguments
@nielsrolf
nielsrolf / utils.py
Last active January 4, 2022 17:02
Code Copy Pasta
# Utility function to copy and paste
cookiecutter gh:nielsrolf/python-best-practices-cookiecutter
conda install -c apple tensorflow-deps
pip install tensorflow-metal
conda install -c huggingface transformers -y
conda env create -f environment.yml
from google.colab import drive
@nielsrolf
nielsrolf / classify-by-reconstruction-error.ipynb
Last active April 21, 2021 19:43
Classify by reconstruction error (autoencoder classifier)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nielsrolf
nielsrolf / vscode.py
Created June 18, 2021 13:43
Colab VSCode workstation
"""
"
Poor man's ML workstation:
Recipe:
1. Auto-setup codeserver on colab
2. Auto-mount google drive and store editor settings and extensions directly on drive
3. Treat a drive folder as home directory
Result:
@nielsrolf
nielsrolf / gradientgenerator.ipynb
Created June 18, 2021 19:59
GradientGenerator.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nielsrolf
nielsrolf / siren-examples.ipynb
Created July 5, 2021 01:25
SIREN-Examples.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<html>
<head>
<script>
window.onload = (() => {
/* Codex output here */
});
</script>
@nielsrolf
nielsrolf / AlgorithmLearningByGradientDescent.ipynb
Created November 17, 2021 17:14
Neural networks for logical tasks, but the weights are probabilities for the effective weight to be either 1 or 0 in the forward pass
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.