Skip to content

Instantly share code, notes, and snippets.

View davebshow's full-sized avatar

David Michael Brown davebshow

  • Vancouver Island
View GitHub Profile

Smoothies: Ingredient and Recipe Recommendation

//Graph written from NetworkX
# -*- coding: utf-8 -*-
from django.db import models
from jsonfield import JSONField
from base.fields import AutoSlugField
from graphs.models import Graph
from operators.models import Query
class ReportTemplate(models.Model):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davebshow
davebshow / reports.json
Created August 20, 2014 15:08
Dummy JSON for reports models
// ReportTemplate JSON
[
[
{
"rowspan":"1",
"colspan":"1",
"id":"cell1",
"chartType":"line",
"displayQuery":"Query1",
@davebshow
davebshow / similarity_qs.ipynb
Last active June 1, 2020 15:12
Using Gensim to make some similarity queries.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# -*- coding: utf-8 -*-
from itertools import chain
import networkx as nx
class ProjX(object):
"""Prototype implementation of a query/schema
manipulation language for NetworkX."""
def __init__(self, graph, type_attr='type'):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Recursive
%timeit parser.parseString('MATCH (c:City)-[l:lives_in]-(p:Person) TRANSFER ATTRS (c)-(p)')
1000 loops, best of 3: 1.7 ms per loop
%timeit parser.parseString('MATCH (p1:Person)-[l1:lives_in]-(c:City)-[l:lives_in]-(p:Person) TRANSFER ATTRS (c)-(p1) PROJECT (p1)-(c)-(p2)')
100 loops, best of 3: 3.22 ms per loop
# Recursive pattern.
%timeit parser.parseString('MATCH (c:City)-[l:lives_in]-(p:Person) TRANSFER ATTRS (c)-(p)')1000 loops, best of 3: 1.58 ms per loop
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.