Skip to content

Instantly share code, notes, and snippets.

@aleju
aleju / start_atom.sh
Last active February 18, 2016 21:43
.sh file to start Atom without any windows/projects opened (i.e. "forget" last session)
#!/bin/bash
# paste this in a sh file, set to executable, run
# delete application.json as it saves your last session's opened windows
rm -f ~/.atom/storage/application.json
# start atom
/usr/bin/atom &
exit 0
@aleju
aleju / quantize.py
Last active February 2, 2023 19:46
Simple quantization function for python
def quantize(val, to_values):
"""Quantize a value with regards to a set of allowed values.
Examples:
quantize(49.513, [0, 45, 90]) -> 45
quantize(43, [0, 10, 20, 30]) -> 30
Note: function doesn't assume to_values to be sorted and
iterates over all values (i.e. is rather slow).