Skip to content

Instantly share code, notes, and snippets.

View jantoniomartin's full-sized avatar

Jose Antonio Martin Prieto jantoniomartin

View GitHub Profile
@jantoniomartin
jantoniomartin / council.py
Last active October 20, 2021 18:36
A simple simulation of TOR council math
#!/usr/bin/env python
import random
def roll(dice, tn):
successes = 0
result = feat = random.randint(0, 11)
for i in range(0, dice):
r = random.randint(1, 6)
result += r
@jantoniomartin
jantoniomartin / listappend.py
Created June 18, 2012 17:42
A Django class based "list and form" view
"""
This generic view displays a list of objects and a simple ModelForm to add a new
object to the list.
Just subclass this view and override the attributes and methods that you need. You
will probably need to override at least 'model', 'form_class' and 'success_url'.
See the documentation of the used mixins and ProcessFormView in
https://docs.djangoproject.com/en/1.4/ref/class-based-views/
"""
from django.views.generic.list import MultipleObjectMixin, MultipleObjectTemplateResponseMixin
from django.views.generic.edit import ModelFormMixin, ProcessFormView
@jantoniomartin
jantoniomartin / prettydf.sh
Created December 16, 2011 13:11
Just for fun, a little script to show a colored output of df
#! /bin/bash
## Just for fun, a little script to show a colored output of df
## to get a prettier view of disk usage
HIGH=80
MEDIUM=50
FIRST=0