Skip to content

Instantly share code, notes, and snippets.

View ooduor's full-sized avatar
🏠
Working from home

Antony Oduor ooduor

🏠
Working from home
View GitHub Profile
@ooduor
ooduor / disk-usage-alert.sh
Created December 22, 2021 03:07 — forked from M1ke/disk-usage-alert.sh
A shell script to check your disk usage and alert you if it hits a limit. Change the value (percentage) in the "if" statement on line 7 to alter the threshold. Change the email address to your email address. See readme for mail.cf instructions and crontab.
#!/bin/sh
df -H | grep -vE '^Filesystem|tmpfs|cdrom' | awk '{ print $5 " " $1 }' | while read output;
do
echo $output
used=$(echo $output | awk '{ print $1}' | cut -d'%' -f1 )
partition=$(echo $output | awk '{ print $2 }' )
if [ $used -ge 80 ]; then
echo "The partition \"$partition\" on $(hostname) has used $used% at $(date)" | mail -s "Disk space alert: $used% used" your@email.com
fi
done
import time
class Retry(object):
default_exceptions = (Exception)
def __init__(self, tries, exceptions=None, delay=0):
"""
Decorator for retrying function if exception occurs
tries -- num tries
exceptions -- exceptions to catch
@ooduor
ooduor / nginx-openssl_build.sh
Last active August 24, 2018 05:37
Add Support for ALPN for Nginx on Ubuntu 14.04. Based on https://gist.github.com/AJMaxwell/f6793605068813aae888216b02364d85 with Extensive Modifications.
#!/bin/bash
##############################################################################################
## Install Nginx with OpenSSL, and ngx_pagespeed
##
## Author: Andrew Maxwell <amaxwell@ajmaxwell.com>
## Date: 2017/09/18
## Version: 0.3
##
## Disclaimer: I am not responsible for how you use this script. Do not assume this script
@ooduor
ooduor / pytest.md
Created April 18, 2018 15:46 — forked from kwmiebach/pytest.md
pytest cheat sheet

Usage

(Remember to create a symlink pytest for py.test)

pytest [options] [file_or_dir] [file_or_dir] ...

Help:

@ooduor
ooduor / view.py
Last active January 5, 2018 22:16
How do go About doing Imperative Schema Construction? I have a survey form, each survey has one of more questions, would like to imperatively construct the form based on the models and also dynamically pick Widgets say Radio Buttons or Checkboxes based since these are stored in the model.
@colander.deferred
def deferred_title(node, kw):
default_title = kw.get('question_name')
if default_title is None:
default_title = "Huh!"
return default_title
@colander.deferred
def deferred_description(node, kw):
some_info = kw.get('some_info')

Keybase proof

I hereby claim:

  • I am ooduor on github.
  • I am lalilulelo (https://keybase.io/lalilulelo) on keybase.
  • I have a public key whose fingerprint is C09B 4C84 7076 1730 DD79 36D9 7B8F 615A DA0A 6D29

To claim this, I am signing this object:

@ooduor
ooduor / keybase.md
Created August 27, 2016 04:45
Verifying my person

Keybase proof

I hereby claim:

  • I am highpriestlol on github.
  • I am lalilulelo (https://keybase.io/lalilulelo) on keybase.
  • I have a public key ASDbGCmcZGaCLBuoyZn3K0tdQwJu3kgtPAs2O_jJtDVj_Ao

To claim this, I am signing this object:

/**
* Continents and Countries MySQL Tables compiled from Wikipedia, Braintree Payments documentation
* and a couple other places I don't recall at the moment. This data is compatible with the Braintree
* Payment API as of Dec 2011
*
* Compiled by Steve Kamerman, 2011
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------