Skip to content

Instantly share code, notes, and snippets.

Avatar

Jose Antonio Martin Prieto jantoniomartin

View GitHub Profile
@jantoniomartin
jantoniomartin / council.py
Last active Oct 20, 2021
A simple simulation of TOR council math
View council.py
#!/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 Jun 18, 2012
A Django class based "list and form" view
View listappend.py
"""
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 Dec 16, 2011
Just for fun, a little script to show a colored output of df
View prettydf.sh
#! /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