Skip to content

Instantly share code, notes, and snippets.

View sinecode's full-sized avatar

Emilio Cecchini sinecode

  • Extendi
  • Florence, Italy
View GitHub Profile
@sinecode
sinecode / contains.sh
Last active August 17, 2020 15:28
Check if an element is in a list in POSIX shell
# Given a list represented as "element1 element2 element3 ..."
# Given an element
# This is a function that returns "yes" or "no" whether the list contains the string
contains() {
# $1 is the list
# $2 is the element to look for
if echo "$1" | grep -q "$2"; then
echo "yes"
else
@sinecode
sinecode / earlystopping.py
Created August 17, 2020 15:35
Python class that implements the Early Stopping method to prevent overfitting
"""
Implementation of the Early stopping method.
Usage:
>>> es = EarlyStopping(patience=2)
>>> es.early_stop
False
>>> es(2)
>>> es.early_stop
False