Skip to content

Instantly share code, notes, and snippets.

View bianchimro's full-sized avatar
🤡

Mauro Bianchi bianchimro

🤡
View GitHub Profile
@bianchimro
bianchimro / example.py
Created July 12, 2023 16:49 — forked from bblanchon/example.py
Django Subquery Aggregate (Count, Sum...)
from django.db.models import OuterRef
weapons = Weapon.objects.filter(unit__player_id=OuterRef('id'))
units = Unit.objects.filter(player_id=OuterRef('id'))
qs = Player.objects.annotate(weapon_count=SubqueryCount(weapons),
rarity_sum=SubquerySum(units, 'rarity'))
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<div class="selected"></div>
<svg id="chart" width="600" height="300"></svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script type="text/javascript">
@bianchimro
bianchimro / nginx.conf
Last active August 29, 2015 14:11 — forked from widoyo/nginx.conf
Deploy Django-Nginx-uwsgi pada web faction
referensi: http://community.webfaction.com/questions/10242/installing-nginx-uwsgi
APPNAME="tracker"
/home/narayana/webapps/tracker
bin
start
stop

DataURI.py

Data URI manipulation made easy.

This isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.

Parsing

# Installing OpenCV python libs on mac to work with virtualenv
# OpenCV 2.4.3
# Python 2.7.3 installed with brew
# assuming you have virtualenv, pip, and python installed via brew
# assuming $WORKON_HOME is set to something like ~/.virtualenvs
# using homebrew - make sure we're current
brew update
"""
This fabric file makes setting up and deploying a django application much
easier, but it does make a few assumptions. Namely that you're using Git,
Apache and mod_wsgi and your using Debian or Ubuntu. Also you should have
Django installed on your local machine and SSH installed on both the local
machine and any servers you want to deploy to.
_note that I've used the name project_name throughout this example. Replace
this with whatever your project is called._