Skip to content

Instantly share code, notes, and snippets.

@alej0varas
alej0varas / django-jsonfield-length-sum-average.py
Created September 2, 2016 14:37
Example usage of database funtions(`Sum` and `Avg`) and Django `JSONField`'s `jsonb_array_length`
# Example usage of database funtions(`Sum` and `Avg`) and Django `JSONField`'s `jsonb_array_length`
# PostgreSQL json field functions: https://www.postgresql.org/docs/9.5/static/functions-json.html
# Django `F` and `Func`: https://docs.djangoproject.com/en/1.10/ref/models/expressions/#f-expressions
# Django aggregation: https://docs.djangoproject.com/en/1.10/topics/db/aggregation/
# Django `JSONField`: https://docs.djangoproject.com/en/1.9/ref/contrib/postgres/fields/#jsonfield
# Given a model
class Contact(models.Model):
numbers = JSONField(help_text="An array of numbers")
@ncole458
ncole458 / _native.scss
Last active January 4, 2016 05:17
Native UI tweaks for Cordova/PhoneGap apps
/*********************************************************************************
Author: Nicholas Cole
Author URI: http://oceanbluecreative.com.au
License: MIT
Usage: Sass Partial for native UI tweaks in Cordova/PhoneGap apps
Gist: https://gist.github.com/ncole458/49bb6b0309572dc429ea
**********************************************************************************/
@yamionp
yamionp / locustfile.py
Last active March 21, 2024 22:56
Websocket Locust Sample. locustfile and Echo/Chat Server
# -*- coding:utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import print_function
import json
import uuid
import time
import gevent