Skip to content

Instantly share code, notes, and snippets.

View adam-cowley's full-sized avatar

Adam Cowley adam-cowley

View GitHub Profile
@adam-cowley
adam-cowley / neo4j-ticketmaster
Created February 17, 2017 16:27
Import Ticketmaster Classifications into Neo4j
CALL apoc.load.json('https://app.ticketmaster.com/discovery/v2/classifications?locale=en-us&apikey={key}') YIELD value AS json
UNWIND json._embedded.classifications as classification
MERGE (seg:Segment {ticketmaster_id: classification.segment.id, name: classification.segment.name})
WITH seg, classification
UNWIND classification.segment._embedded.genres as genre
MERGE (gen:Genre {ticketmaster_id: genre.id, name: genre.name})
MERGE (seg)-[:HAS_GENRE]->(gen)
WITH seg, gen, genre
UNWIND genre._embedded.subgenres as subgenre
MERGE (sub:SubGenre {ticketmaster_id: subgenre.id, name: subgenre.name})
@adam-cowley
adam-cowley / queue.js
Created September 28, 2016 09:29
Run an array of promises one by one
function queue(all) {
return new Promise((resolve, reject) => {
const output = [];
next(all.splice(0, 1))
function next(go) {
go();
.then(res => {
output.push(res);
== Northwind Graph
=== Introduction
Recently, I was asked to pitch a method for providing recommendations. Luckily, armed with the knowledge obtained from talks from Max De Marzi and [Mark Needham](https://skillsmatter.com/skillscasts/7298-modelling-a-recommendation-engine-a-worked-example) at a recent Neo4j London Meetups, I knew this could be easily achieved with Neo4j.
The key issue with recommendation engines comes from the data. Luckily, Neo4j comes bundled with the Northwind Graph Example. The Northwind database is an infamous dataset containing purchase history that has been used to teach relational databases for years and was a great place to start. You can import the Northwind database into a graph by following the ["Import Data into Neo4j"](http://neo4j.com/developer/guide-importing-data-and-etl/) post on Neo4j or type the following into Neo4j's browser at `http://localhost:7474/`
:play northwind graph