Skip to content

Instantly share code, notes, and snippets.

View rdammkoehler's full-sized avatar

Rich Dammkoehler rdammkoehler

View GitHub Profile
@rdammkoehler
rdammkoehler / timed_decorator.py
Created October 10, 2024 20:10
Python Timing Decorator (simple)
import logging
from datetime import datetime
import time
def timed(method):
def _timed(*args, **kwargs):
start_time = time.time()
result = method(*args, **kwargs)
end_time = time.time()
@rdammkoehler
rdammkoehler / validateWithExceptions.js
Created January 20, 2023 06:17
Example Validation using Exceptions
function validate(httpReq) {
const body = JSON.parse(httpReq.body);
if (!body.hasOwnProperty('name')) {
throw new Error('invalid request');
}
}
@rdammkoehler
rdammkoehler / kill_zoom_server.sh
Created July 9, 2019 18:41
Mac Users: Kill the Zoom.us server running on your machine and disable it permanently in one line!
# for details see this article
# https://medium.com/@jonathan.leitschuh/zoom-zero-day-4-million-webcams-maybe-an-rce-just-get-them-to-visit-your-website-ac75c83f4ef5
lsof -i :19421 | tail -1 | awk '{print $2}' | xargs -I {} kill -9 {} && rm -Rf ~/.zoomus && touch ~/.zoomus
pair = :you
pear = :fruit
join = :happy
pair
pair
pair
pear
pair
pair
pair
@rdammkoehler
rdammkoehler / monk.cow
Last active August 3, 2023 16:19
A Monk for cowsay
$the_cow = <<EOC;
$thoughts _=_
$thoughts q(-_-)p
$thoughts '_) (_`
/__/ \\
_(<_ / )_
(__\\_\\_|_/__)
EOC
# this might be a comment
### Keybase proof
I hereby claim:
* I am rdammkoehler on github.
* I am individualrich (https://keybase.io/individualrich) on keybase.
* I have a public key ASA7Htyss5Qw0rmd4M7KRRl-Bhlrtlbp8vc4FFm26bCdQQo
To claim this, I am signing this object:
@rdammkoehler
rdammkoehler / find_largest.sh
Last active April 16, 2018 22:09
Find the Largest Files on your Disk
sudo du -kx 2>/dev/null | sort -nr > /tmp/du-k.sort
@rdammkoehler
rdammkoehler / collect_versions.sh
Created March 8, 2018 04:18
A one-liner to collect the versions of all your python dependancies via pip.
pip list --format columns | tail "-n $(expr $(pip list --format columns | wc -l) - 2)" | awk '{print $1}' | xargs -I {} bash -c "pip show {} | grep -v Summary | grep -v Home-page: | grep -v Author | grep -v Location | grep -v Requires | tr '\n' ' ' | awk '{print $1}'" | awk '{print $2,$4,$6}'
find . -type f -exec stat --format '%Y :%y %n' "{}" \; | sort -nr | cut -d: -f2- > /root/latest_files.txt
@rdammkoehler
rdammkoehler / foo.py
Last active May 15, 2017 14:59
Moise Foo.py
from unittest import TestCase
import nose.tools as nt
def foo(x,y):
return (x+y), (x*y)
class FooTests_2(TestCase):
def __execute_foo(self, x, y):