Skip to content

Instantly share code, notes, and snippets.

@gzcf
gzcf / find_if_by_mac.sh
Created September 26, 2021 09:36
Find interface in all namespaces by mac address
#!/bin/bash
# usage: ./find_if_by_mac.sh d4:3a:65:08:13:7e
function get_if_name() {
name=`echo "$1" | awk '{print $2}' | sed 's/:$//'`
echo $name
}
mac=$1
@gzcf
gzcf / stats.sh
Created August 27, 2021 09:09
Calculate data statistics in bash, including pencentile, min, max, average, standard deviation. Suitable for inspecting system latencies distribution.
#!/bin/bash
# Calculate data statistics, including pencentile, min, max, average, standard deviation.
# Derived from https://gist.github.com/lewisd32/4be2605400acf0bb562d
#
# Usage & Output
# $ cat nums.txt | ./stats.sh
# total 100
# p50 49
# p90 89
# p95 94
@gzcf
gzcf / ViewProfilerMiddleware.py
Created June 26, 2018 08:16
Using cProfile module to profile django views' performances.
from django.utils.deprecation import MiddlewareMixin
class ViewProfilerMiddleware(MiddlewareMixin):
def process_request(self, request):
self._pr = cProfile.Profile()
self._pr.enable()
def process_response(self, request, response):
self._pr.disable()