Skip to content

Instantly share code, notes, and snippets.

Avatar

Mario Staykov insideClaw

View GitHub Profile
@insideClaw
insideClaw / server.py
Created Aug 23, 2021 — forked from mdonkers/server.py
Simple Python 3 HTTP server for logging all GET and POST requests
View server.py
#!/usr/bin/env python3
"""
Very simple HTTP server in python for logging requests
Usage::
./server.py [<port>]
"""
from http.server import BaseHTTPRequestHandler, HTTPServer
import logging
class S(BaseHTTPRequestHandler):
@insideClaw
insideClaw / cpuUsageByPID
Created Aug 28, 2014
Snippet to get CPU usage per process. Takes PID as an argument.
View cpuUsageByPID
#!/bin/bash
if [ $# != 1 ]; then
echo "Usage: Provide the PID to check for CPU usage as an argument."
exit 1
else
PID=$1
fi
sleep 1 && pkill prstat &
prstat -p $PID | grep .*\..% | awk '{ print $9 }'