Skip to content

Instantly share code, notes, and snippets.

View guglielmo's full-sized avatar

Guglielmo Celata guglielmo

View GitHub Profile
@guglielmo
guglielmo / Municipality.py
Created March 7, 2012 20:20
Open Municipio Internal Municipality API
## Private DB access API
class Council(object):
@property
def members(self):
return Institution.objects.get(institution_type=Institution.COUNCIL).institutioncharge_set
@property
def majority_members(self):
pass
@guglielmo
guglielmo / deliberation.py
Created April 17, 2012 12:56
Deliberation class definition
class Deliberation(Act):
"""
WRITEME
"""
INIZIATIVE_CHOICES = Choices(
('COUNSELOR', 'counselor', _('Counselor')),
('PRESIDENT', 'president', _('President')),
('ASSESSOR', 'assessor', _('City Government Member')),
('GOVERNMENT', 'government', _('City Government')),
('MAYOR', 'mayor', _('Mayor')),
@guglielmo
guglielmo / mixins.py
Created January 29, 2013 18:48
This code is related to the django rest framework project (https://github.com/tomchristie/django-rest-framework). It's an implementation of the suggestion of Alan Plum in this google groups discussion (https://groups.google.com/forum/?fromgroups=#!topic/django-rest-framework/XRHdi8ddXiw) to have different representations of list and detail views…
from django.http import Http404
from rest_framework.mixins import ListModelMixin
from rest_framework.response import Response
class ShortListModelMixin(ListModelMixin):
"""
Extends ListModelMixin,
allowing the specification of the list_fields arguments for the .list() method
different fields can be shown for list and detail views
"""
@guglielmo
guglielmo / places.py
Last active December 30, 2015 15:59
Code to reproduce a probable issue within django-rest-framework. A Place may have many acronyms. The reverse fk relationship ('acronyms') is serialized with a nested AcronymSerializer. When issuing PUT to edit the place, the old acronyms not in the json payload anymore, are not removed from the DB. The HTML form shows the error: non_field_errors…
## Models
class Place(models.Model):
name = models.CharField(max_length=255, blank=True)
slug = models.SlugField(max_length=255, null=True, blank=True)
class PlaceAcronym(models.Model):
place = models.ForeignKey('Place', related_name="acronyms")
acronym = models.CharField(_("acronym"), max_length=128,
help_text=_("An acronym for the place, e.g. 'PV'")
)
# simple uWSGI script
description "uwsgi emperor"
start on runlevel [2345]
stop on runlevel [06]
exec /usr/local/bin/uwsgi --emperor /etc/uwsgi/vassals --uid www-data --gid www-data --daemonize=/var/log/uwsgi/emperor.log
@guglielmo
guglielmo / ansibleSetupPostfixSES.yml
Last active March 3, 2016 09:57 — forked from l0neranger/ansibleSetupPostfixSES.yml
Ansible Playbook - Postfix for SES Delivery
#
# According to AWS Docs - http://docs.aws.amazon.com/ses/latest/DeveloperGuide/postfix.html
#
# Rewrites all sender addresses to a single canonical ses verified address.
#
# Expects a vars files at ../vars/PostfixSES-vars.yml with the following variables:
# - ses_host: email-smtp.us-west-x.amazonaws.com
# - ses_port: 587
# - ses_username: ses-smtp-username
# - ses_password: ses-smtp-password
@guglielmo
guglielmo / # graph-tool - 2017-02-28_08-19-11.txt
Created February 28, 2017 08:17
graph-tool (homebrew/science/graph-tool) on macOS 10.11.6 - Homebrew build logs
Homebrew build logs for homebrew/science/graph-tool on macOS 10.11.6
Build date: 2017-02-28 08:19:11
@guglielmo
guglielmo / migrate_repo.sh
Last active May 29, 2017 11:07 — forked from mariozig/migrate_repo.sh
Migrate repo from GitLab to GitHub Full blog post @ http://ruby.zigzo.com/2015/03/23/moving-from-gitlab-to-github/
# Assume we are in your home directory
cd ~/
# Clone the repo from GitLab using the `--mirror` option
$ git clone --mirror git@your-gitlab-site.com:guglielmo/my-repo.git
# Change into newly created repo directory
$ cd ~/my-repo.git
# Push to GitHub using the `--mirror` option. The `--no-verify` option skips any hooks.
@guglielmo
guglielmo / .block
Last active August 31, 2018 15:42 — forked from JacquesJahnichen/README.md
d3.js v4 - Interactive zoomable treemap
license: gpl-3.0
height: 600
@guglielmo
guglielmo / .block
Last active September 1, 2017 14:17
d3.js v4 - Zoomable treemap
license: gpl-3.0
height: 600