Skip to content

Instantly share code, notes, and snippets.

View MakersF's full-sized avatar

Francesco Zoffoli MakersF

View GitHub Profile
@MakersF
MakersF / Result
Last active December 17, 2015 06:04
Example of (incomplete) implementation of reverse IN, or better the SQL for "value IN (column, colum, column, ..)". Basically working, but it's clumsy to use a filed to trigger the lookup and then ignore it, but still having the constraint of it being the same type of the querried fields
>>> from teamcomp.models import TableA as ta
>>> from django.db.models import F
>>> q = ta.objects.filter(fieldA_A__revin=(1, (F("foreign1"),))).values("id")[:1]
>>> str(q.query)
'SELECT "TableA"."id" FROM "TableA" WHERE 1 IN ( ("TableA"."foreign1") ) LIMIT 1'
>>> q = ta.objects.filter(games__revin=(1, (F("foreign1"),F("foreign2"),F("foreign3")))).values("id")[:1]
>>> str(q.query)
'SELECT "TableA"."id" FROM "TableA"
WHERE 1 IN ( ("TableA"."foreign1"), ("TableA"."foreign2"), ("TableA"."foreign3") )
@MakersF
MakersF / cloud_config.yaml
Created December 31, 2015 06:26
#cloud-config for Python application with Postgresql database and read_only role for DigitalOcean
#cloud-config
users:
- name: demo_user
shell: /bin/bash
ssh-authorized-keys:
- ssh-rsa [your -key]
packages:
- git
@MakersF
MakersF / Console out
Created June 8, 2017 18:59
Workspace-d error
./workspace-d
Config files stored in ["/home/username/.config/workspace-d", "/etc/xdg/xdg-xubuntu/workspace-d", "/usr/share/upstart/xdg/workspace-d", "/etc/xdg/workspace-d"]
{"something":12}
std.json.JSONException@std/json.d(1300): Unexpected character 'i'. (Line 1:1)
----------------
??:? @safe void std.json.parseJSON!(immutable(char)[]).parseJSON(immutable(char)[], int, std.json.JSONOptions).parseValue(ref std.json.JSONValue) [0x8c1df0]
??:? @safe std.json.JSONValue std.json.parseJSON!(immutable(char)[]).parseJSON(immutable(char)[], int, std.json.JSONOptions) [0x8c0cf9]
??:? _Dmain [0x8934cc]