Skip to content

Instantly share code, notes, and snippets.

View wassname's full-sized avatar
🙃

wassname (Michael J Clark) wassname

🙃
  • I'm just a guy who likes to machine learn
  • IAU #90377 (Sedna), IAU #137924 (2000 BD19), IAU #85770 (1998 UP1), IAU #66063 (1998 RO1), and minor planet 1992 TY₁. from 2025 Feb 25.
  • X @wassname
  • LinkedIn in/mclark52
View GitHub Profile
@wassname
wassname / 1.generate_dockerignore.py
Last active July 21, 2022 13:50
Convert .gitignore to .dockerignore: quick and dirty.
"""
Convert .gitignore to .dockerignore: quick and dirty.
This is a quick and dirty script to convert this:
`__pycache__/`
Into this:
```
__pycache__
*/__pycache__
@wassname
wassname / permutations.js
Last active June 28, 2022 22:53
Combinatorics permutatons and product in javascript using lodash.js (like python's itertools)
/**
* Lodash mixins for combinatorics
* by: wassname & visangela
* url: https://gist.github.com/wassname/a882ac3981c8e18d2556/edit
* lodash contrib issue: https://github.com/node4good/lodash-contrib/issues/47
* lic: same as lodash
* Inspired by python itertools: https://docs.python.org/2.7/library/itertools.html
*
* Usage:
* permutations([0,1,2],2) // [[0,1],[0,2],[1,0],[1,2],[2,0],[2,1]]
@wassname
wassname / .eslintrc.js
Last active April 15, 2025 06:10
eslint.recommended (annotated)
/**
* eslint.recommended (annotated)
* ================
* Annotated defaults based on eslint.recommended
*
* @author: wassname
* @license: MIT
* @website https://gist.github.com/wassname/4693303388396c5f074b10865a969b43
* @date 2017-11-13T23:08
* @eslint-version: 4.11.0
@fvisin
fvisin / running_stats.py
Last active May 31, 2019 04:06
Running stats
class RunningStats:
"""Computes running mean and standard deviation
Adapted from:
*
<http://stackoverflow.com/questions/1174984/how-to-efficiently-\
calculate-a-running-standard-deviation>
* <http://mathcentral.uregina.ca/QQ/database/QQ.09.02/carlos1.html>
"""
def __init__(self):
@the-winter
the-winter / Array-1 CodingBat JavaScript.ipynb
Created August 4, 2016 07:54
CodingBat/NodingBat JavaScript answers
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@wassname
wassname / keras_weighted_categorical_crossentropy.py
Last active October 10, 2024 00:52
Keras weighted categorical_crossentropy (please read comments for updated version)
"""
A weighted version of categorical_crossentropy for keras (2.0.6). This lets you apply a weight to unbalanced classes.
@url: https://gist.github.com/wassname/ce364fddfc8a025bfab4348cf5de852d
@author: wassname
"""
from keras import backend as K
def weighted_categorical_crossentropy(weights):
"""
A weighted version of keras.objectives.categorical_crossentropy
@asross
asross / figure_grid.py
Last active September 7, 2018 14:44
A helper to plot grids of graphs in matplotlib.pyplot
"""
Examples:
with figure_grid(5, 3) as grid:
grid.next()
# plot something
grid.next()
# plot something
# ...etc
@wassname
wassname / keras_attention_wrapper.py
Created November 1, 2016 08:06
A keras attention layer that wraps RNN layers.
"""
A keras attention layer that wraps RNN layers.
Based on tensorflows [attention_decoder](https://github.com/tensorflow/tensorflow/blob/c8a45a8e236776bed1d14fd71f3b6755bd63cc58/tensorflow/python/ops/seq2seq.py#L506)
and [Grammar as a Foreign Language](https://arxiv.org/abs/1412.7449).
date: 20161101
author: wassname
url: https://gist.github.com/wassname/5292f95000e409e239b9dc973295327a
"""
@Kaixhin
Kaixhin / prob-notation.md
Last active November 15, 2018 11:25
Probability notation

Probability notation

Note: Great refresher/glossary on probability/statistics and related topics here

Notation Definition
X Random variable
P(X) Probability distribution over random variable X
X ~ P(X) Random variable X follows (~) the probability distribution P(X) *
@wassname
wassname / to_filename.py
Last active March 14, 2025 09:54
python convert string to safe filename
"""
Url: https://gist.github.com/wassname/1393c4a57cfcbf03641dbc31886123b8
"""
import unicodedata
import string
valid_filename_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
char_limit = 255
def clean_filename(filename, whitelist=valid_filename_chars, replace=' '):