Skip to content

Instantly share code, notes, and snippets.

class PandasFloatFormatter:
def __init__(self, new_format: str):
self.new_format = new_format.format
self.old_format = None
def __enter__(self):
self.old_format = pandas.options.display.float_format
pandas.options.display.float_format = self.new_format
def __exit__(self, exc_type, exc_val, exc_tb):
@MJafarMashhadi
MJafarMashhadi / check_nan.py
Created June 16, 2020 07:20
A tensorflow layer that prints a warning mesage if there is a `nan` or `inf` in a layer's output.
@tf.function
def has_nan(X):
return tf.math.reduce_any(tf.math.is_nan(X))
@tf.function
def has_inf(X):
return tf.math.reduce_any(tf.math.is_inf(X))
def check_nan(name):
@tf.function
  1. Run the unit tests of Apache commons math.

  2. Use JInstrumenter to generate an execution log of the program. Make changes to the instrumenter and/or it's configurations as neccessary.

  3. Feed the execution traces MINT to infer a model representing the behavior of commons math library. You will need to preprocess the execution traces to make them in the format that MINT can read. Make changes to the tool's configuration as neccessary.

#!/bin/sh
md5sum * 2>/dev/null | cut -c 2-3 | uniq | xargs mkdir
for f in *; do
if [ -f $f ]; then
mv "$f" $(md5sum "$f" | cut -c 2-3)
fi
done
#!/bin/sh
#
# Usage:
# ./android-backup.sh com.example.app [example_backup]
#
# Outputs com.example.app.tar or if second parameter is provided, example_backup.tar
#
# Tarfile contains application private data such as database, shared preferences and internal files.
#
def shima_proof(string):
if not string:
return ''
if string[-1] in {u'ا', u'و'}
return u'%sی' % stirng
return string