This GraphGist is inspired by the blog Building a follower model from scratch, kudos to the Pinterest Engineers!
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
body, div, h1, h2, h3, h4, h5, h6, p, ul, ol, li, dl, dt, dd, img, form, fieldset, input, textarea, blockquote { | |
margin: 0; padding: 0; border: 0; | |
} | |
body { | |
margin: 200px; | |
font-family: Helvetica; | |
background: white; | |
} |
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 redis import Redis | |
import simplejson | |
class Resque(object): | |
"""Dirt simple Resque client in Python. Can be used to create jobs.""" | |
redis_server = 'localhost:6379' | |
def __init__(self): | |
host, port = self.redis_server.split(':') | |
self.redis = Redis(host=host, port=int(port)) |
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
MATCH (n1:node { n.id = "1234" }) | |
MATCH (n0)-[r1]->(n1)-[r2]->(n2) | |
DELETE r1, n1, r2 | |
MERGE (n0)-[:NEXT]->(n2) |
- Write functions() in lower case, KEYWORDS in upper.
START
each keyword clause
ON
a new line.- Use either
camelCase
orsnake_case
for node identifiers but be consistent. - Relationship type names should use
UPPER_CASE_AND_UNDERSCORES
. - Label names should use
CamelCaseWithInitialCaps
. MATCH (clauses)-->(should)-->(always)-->(use)-->(parentheses)-->(around)-->(nodes)
- Backticks `cân éscape odd-ch@racter$ & keyw0rd$` but should be a code smell.
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
= C Graph | |
:neo4j-version: 2.0.0-RC1 | |
''' | |
//setup | |
//hide | |
== Initial Data Setup | |
//person1 WORKED_AT company1 | |
//person1 WORKED_AT company2 |
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
BEARER='...' | |
def load_tweets(query,since_id=nil,lang="en",page=1,rpp=100) | |
res=RestClient.get('https://api.twitter.com/1.1/search/tweets.json', | |
{:params=> {:q=>query, :lang=>lang,:count=>rpp,:result_type=>:recent,:since_id=>since_id}, | |
:accept=>:json, | |
:Authorization => "Bearer #{BEARER}"}) | |
puts "query '#{query}'\n since id #{since_id} result #{res.code}" | |
return [] unless res.code==200 | |
data=JSON.parse(res.to_str) |
Answering an Stackoverflow Question.
I am learning Neo4j and decided to take one of the sample queries and add a twist to it. I took this example http://docs.neo4j.org/chunked/stable/cypher-cookbook-co-favorited-places.html and wanted to say what if there was an additional attribute that you could use to filter the results by. My test I put together was to have tags in the graph as well and then I wanted to search by overlapped favorites desc then by overlapping tags desc.
Here is the sample data I am using:
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
<link rel="import" href="../components/polymer/polymer.html"> | |
<polymer-element name="my-element"> | |
<template> | |
</template> | |
<script> |
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
<link rel="import" href="../components/polymer/polymer.html"> | |
<polymer-element name="my-element"> | |
<template> | |
<style> | |
:host { | |
position: absolute; | |
width: 100%; | |
height: 100%; |