This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
START n=node({startId}) | |
MATCH (n)-[?:DID]->(thing) | |
WITH thing, (thing.year? = null) AS year_is_null | |
WITH thing, STR(year_is_null) as null_year | |
ORDER BY null_year, thing.year? DESC | |
RETURN thing, thing.year? as year |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import neo4django | |
from neo4django.db import models | |
class Preceding(models.NodeModel): | |
precedes_events = model.Relationship('Condition',reltype=neo4django.Outgoing.PRECEDES_CONDITION) | |
precedes_conditions = model.Relationship('Event', reltype=neo4django.Outgoing.PRECEDES_EVENT) | |
class Event(Preceding): | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from neo4django.db import models | |
class BlogPost(models.NodeModel): | |
def __init__(self, user, contents): | |
self.by_user = user.id | |
self.contents = contents | |
by_user = models.IntegerProperty(indexed=True) | |
contents = models.StringProperty() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pymaps import PyMap | |
class MyPyMap(PyMap): | |
#old-style classes, unfortunately | |
def _mapjs(self, map): | |
super_js = PyMap._mapjs(self, map) | |
return super_js + 'PyMaps.push(%s);\n' % map.id | |
def _buildmaps(self): | |
super_js = PyMap._buildmaps(self) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import orcid | |
>>> cs_authors = orcid.search('computer science') | |
>>> print cs_authors.next() | |
<Author Olga Zhelenkova, ORCID 0000-0003-0028-2469> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a hack for pete.groups.filter(created_date__gt = datetime.date(2012,1,1), type__type = "Chess Club") | |
import datetime | |
import neo4django | |
from neo4django.db import models | |
class Person(models.NodeModel): | |
auto_id = models.AutoProperty(indexed=True) | |
groups = models.Relationship('Group', related_name='people', | |
rel_type=neo4django.Outgoing.MEMBER_OF) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vagrant@nettuno:~$ cd ~/builds | |
vagrant@nettuno:~/builds$ export TRAVIS_PULL_REQUEST=false | |
vagrant@nettuno:~/builds$ export TRAVIS_SECURE_ENV_VARS=false | |
vagrant@nettuno:~/builds$ export NEO4J_VERSION="1.6.3" | |
vagrant@nettuno:~/builds$ git clone --depth=100 --quiet git://github.com/mhluongo/neo4django.git mhluongo/neo4django | |
vagrant@nettuno:~/builds$ cd mhluongo/neo4django | |
vagrant@nettuno:~/builds/mhluongo/neo4django$ git checkout -qf 155c266129d2d587b39e5d7acff86b123c94dda7 | |
vagrant@nettuno:~/builds/mhluongo/neo4django$ export TRAVIS_PYTHON_VERSION=2.6 | |
vagrant@nettuno:~/builds/mhluongo/neo4django$ source ~/virtualenv/python2.6/bin/activate | |
vagrant@nettuno:~/builds/mhluongo/neo4django$ python --version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from neo4django.db import models | |
import neo4django | |
class Concept(models.NodeModel): | |
name = models.StringProperty(indexed=True) | |
class ContainerConcept(Concept): | |
class Meta: | |
abstract = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VERSION='1.6' | |
DIR="neo4j-community-$VERSION" | |
FILE="$DIR-unix.tar.gz" | |
SERVER_PROPERTIES_FILE="lib/neo4j/conf/neo4j-server.properties" | |
if [[ ! -d lib/$DIR ]]; then | |
wget http://dist.neo4j.org/$FILE | |
tar xvfz $FILE &> /dev/null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# a hack for `NodeA.objects.filter(nodeb__in=nodebnodes)` | |
from neo4django.db import connections | |
from neo4django.db.models.script_utils import LazyNode | |
# ... | |
b_nodes = set([...]) #your NodeB instances | |
b_node_ids = [b.id for b in b_nodes] | |
type_node_a = NodeA._type_node() |