Skip to content

Instantly share code, notes, and snippets.

View InbarRose's full-sized avatar

Inbar InbarRose

  • OX Security
View GitHub Profile
@InbarRose
InbarRose / check_cpu_above_threshold_one_line_status_script.sh
Last active July 26, 2022 11:59
single line script to check if the CPU usage is above a certain threshhold on the device. and return exit code 0 if not, 1 if it is.
cpu_threshhold=80 ; cpu_idle=$(top -b -n 1 | grep Cpu | awk '{print $8}'|cut -f 1 -d '.') ; cpu_usage=$(expr 100 - $cpu_idle) ; if [ $cpu_usage -gt $cpu_threshhold ]; then exit 1; else exit 0; fi
@InbarRose
InbarRose / fix_symlinks.sh
Created June 26, 2019 11:33
fix symlinks that have backslashes instead of slashes (such as when copying them into docker from windows)
@InbarRose
InbarRose / recursive_dict_compare_dispatch.py
Created July 26, 2018 08:17
an attempt at some fancy abstract dict compare dispatching
def __recursive_dict_compare_dispatch(self, dict_data, dict_conf, **kwargs):
# get dispatchers from kwargs // do not pop them out, we need them to recurse
isinstance_dispatch = kwargs.get('isinstance_dispatch')
issubclass_dispatch = kwargs.get('issubclass_dispatch')
no_handle_dispatch = kwargs.get('no_handle_dispatch')
raise_no_dispatch = kwargs.get('raise_no_dispatch', True)
# loop over all the keys in this layer of the defaults
for conf_key, conf_value in dict_conf.items():
# we should only enter one of these conditions
# check for isinstance condition and dispatch
@InbarRose
InbarRose / hyperslice.py
Last active August 29, 2015 14:19
hyperslice.py
from operator import itemgetter
def hyperslice(iterable, *args):
if len(args) == 1 and isinstance(args[0], str):
return itemgetter(*map(slice_or_index, args[0].split(',')))(iterable)
elif args:
return itemgetter(*args)(iterable)
else:
return iterable