Skip to content

Instantly share code, notes, and snippets.

View wassname's full-sized avatar
🙃

Michael J Clark wassname

🙃
View GitHub Profile
@wassname
wassname / aws_keepassxc.md
Created September 1, 2020 06:04
How to use keepassxc and browser integration with aws console sign's

For your IAM user you get a csv of credentials like this

User name,Password,Access key ID,Secret access key,Console login link
USERNAME,PASSWORD,ACCESS_KEY,SECRET_KEY,https://0123456.signin.aws.amazon.com/console

If your region is sydney (ap-southeast-2) in keepass you enter:

Title: USERNAME/COMPANY

@bdsaglam
bdsaglam / hydra_in_jupyter.py
Last active April 29, 2024 08:53
Use Hydra in Jupyter notebook
import pathlib
import hydra
hydra._internal.hydra.GlobalHydra().clear()
config_dir = pathlib.Path('/path/to/configs/')
hydra.experimental.initialize(config_dir=config_dir)
cfg = hydra.experimental.compose(config_file='config.yaml', overrides=[])
print(cfg.pretty())
@fclesio
fclesio / get_classification_report.py
Created March 4, 2020 12:21
Scikit Learn Classification Report in Dataframe
def get_classification_report(y_test, y_pred):
'''Source: https://stackoverflow.com/questions/39662398/scikit-learn-output-metrics-classification-report-into-csv-tab-delimited-format'''
from sklearn import metrics
report = metrics.classification_report(y_test, y_pred, output_dict=True)
df_classification_report = pd.DataFrame(report).transpose()
df_classification_report = df_classification_report.sort_values(by=['f1-score'], ascending=False)
return df_classification_report
@wassname
wassname / dataset_cache_with_dask.py
Last active May 29, 2020 02:09
Cache a torch dataset to npy files using dask
"""
Cache a torch dataset to npy files using dask
url:https://gist.github.com/wassname/f38f8774b6f97977b660d20dfa0f0036
lic:MIT
author:wassname
usage:
batch_size=16
chunk_size=batch_size*4
@soxofaan
soxofaan / here-jupyter.sh
Last active March 23, 2021 23:34
here-jupyter: launch Jupyter Notebook in background from current directory using tmux
#!/bin/bash
# Build tmux session name from current directory
SESSION_NAME=$(pwd)
# Strip non-alphanumeric characters
SESSION_NAME=${SESSION_NAME//[^a-zA-Z0-9]/}
# Only keep trailing part
SESSION_NAME=Jupyter-${SESSION_NAME: -20}
# Command to run inside tmux session
@wassname
wassname / pandas_classification_report.py
Last active January 19, 2024 06:28
Scikit Learn Classification Report in a pandas Dataframe (and confusion)
"""
@url: https://gist.github.com/wassname/f3cbdc14f379ba9ec2acfafe5c1db592
"""
import pandas as pd
import sklearn.metrics
import numpy as np
def classification_report(*args, **kwargs):
"""
@wassname
wassname / running_stats.py
Last active November 14, 2023 15:09
Running stats (mean, standard deviation) for python, pytorch, etc
import numpy as np
# handle pytorch tensors etc, by using tensorboardX's method
try:
from tensorboardX.x2num import make_np
except ImportError:
def make_np(x):
return np.array(x).copy().astype('float16')
class RunningStats(object):

I decided to write this guide because I have been pretty happy recently. I would go as far as to say that I am the happiest I’ve ever been (in a sustained way) in my adult life, and completely independent of my external circumstances. This is how I’ve done it.

Background In our society today it is easy to get caught on the hedonic treadmill: the belief that happiness is just around the corner if one can only achieve the next milestone, or experience the next life experience. This is a trap. As someone who has achieved more and more success over time, and experienced more and more fun, positive, exciting things, no achievement or experience has ever resulted in a sustained increase to baseline happiness for me.

Expectations for how you will feel once you achieve your goal lead to an endless cycle of suffering. Either you get what you want and then set new, higher, loftier goals, or you don’t get what you want and end up feeling miserable. In The Score Takes Care of Itself, Bill Walsh tells of winning three S

@wassname
wassname / linux_x380.md
Last active February 5, 2024 17:43
xubuntu on a Thinkpad Yoga x380

This are a collection of fixes and tweaks I used to get Xubuntu 18.04 LTS working on a lenovo thinkpad X380 yoga laptop.

@yang-zhang
yang-zhang / cross-entropy.ipynb
Last active March 18, 2024 06:05
Cross entropy implementation in pytorch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.