Skip to content

Instantly share code, notes, and snippets.

View johnymontana's full-sized avatar
🤠
I'm very normal

William Lyon johnymontana

🤠
I'm very normal
View GitHub Profile
@johnymontana
johnymontana / coffee.ipynb
Created January 30, 2013 19:38
CSCI 577 - Coffee Cooling
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
{
"metadata": {
"name": "Coffee_Cooling"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
{
"metadata": {
"name": "Simple_ODEs_Conservation"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@johnymontana
johnymontana / options.adoc
Last active May 17, 2023 13:10
My entry for the Neo4j GraphGist December competition. Very simplified options trading in a graph.

Options Trading As A Graph


Introduction

This GraphGist will begin to explore how stock option data can be modeled as a graph, some simple Cypher queries for calculating payout at expiration for an options contract and a very basic look at finding profitable options trades given a specific forecast. Please note that some of the concepts here have been simplified and are only meant as an educational overview of exploring Neo4j and graph data modeling.

@johnymontana
johnymontana / FEC-2015.cql
Last active October 6, 2015 20:41
FEC Import
// Import Federal Election campaign contribution data into Neo4j
// /path/to/neo4j/bin/neo4j-shell < FEC-2015.cql
//first let us create indexes!
CREATE INDEX ON :Candidate(fullName);
CREATE INDEX ON :Candidate(lastName);
CREATE INDEX ON :Candidate(candidateID);
CREATE INDEX ON :Contributor(fullName);
CREATE INDEX ON :Contributor(occupation);
@johnymontana
johnymontana / import.cypher
Last active November 9, 2015 23:36
Import orgs
MATCH n
OPTIONAL MATCH n-[r]->()
DELETE n,r;
LOAD CSV FROM 'https://dl.dropboxusercontent.com/u/67572426/persons.csv' AS line
MERGE (p:Person:Entity {name: line[0]});
LOAD CSV FROM 'https://dl.dropboxusercontent.com/u/67572426/orgs.csv' AS line
MERGE (o:Org:Dept:Entity {name: line[0]});
@johnymontana
johnymontana / FEC.cypher
Created March 10, 2016 00:16
Importing FEC data into Neo4j. Download data files here: http://www.fec.gov/finance/disclosure/ftpdet.shtml#a2015_2016
// Create schema constraints
CREATE CONSTRAINT ON (c:FECCommittee) ASSERT c.committee_id IS UNIQUE;
CREATE CONSTRAINT ON (t:Treasurer) ASSERT t.name IS UNIQUE;
CREATE CONSTRAINT ON (c:Contributor) ASSERT c.name IS UNIQUE;
CREATE CONSTRAINT ON (o:Occupation) ASSERT o.name IS UNIQUE;
CREATE CONSTRAINT ON (e:Employer) ASSERT e.name IS UNIQUE;
CREATE CONSTRAINT ON (c:City) ASSERT c.name IS UNIQUE;
// FEC Committees
USING PERIODIC COMMIT
@johnymontana
johnymontana / uk_crime_data.cypher
Last active April 25, 2016 08:58
Travel hackathon datasets with Neo4j
// data available here: https://data.police.uk/data/
// Load data for City of London 2015. Change URL for other data downloaded from https://data.police.uk/data/
LOAD CSV WITH HEADERS FROM "https://dl.dropboxusercontent.com/u/67572426/london_graph_hack/2015-01-city-of-london-street.csv" AS row
WITH row WHERE row.Location IS NOT NULL AND row.Latitude IS NOT NULL AND row.Longitude IS NOT NULL AND row.Month IS NOT NULL AND row.`Falls within` IS NOT NULL AND row.`Reported by` IS NOT NULL AND row.`Crime type` IS NOT NULL AND row.`Crime ID` IS NOT NULL
MERGE (location:Location {name: row.Location})
MERGE (point:Point {lat: row.Latitude, lon: row.Longitude})
MERGE (month:Month {name: row.Month})
MERGE (juris:Jurisdiction {name: row.`Falls within`})
MERGE (report:Reporter {name: row.`Reported by`})
@johnymontana
johnymontana / gist:45009185d59c24e08cb4f3f8053546e5
Created April 25, 2016 15:34
Load Airports into Neo4j Spatial
// Load airports from Openflights.org dataset
CREATE CONSTRAINT ON (c:Country) ASSERT c.name IS UNIQUE;
CREATE CONSTRAINT ON (c:City) ASSERT c.name IS UNIQUE;
CREATE CONSTRAINT ON (a:Airport) ASSERT a.id IS UNIQUE;
LOAD CSV FROM "https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat" AS row
WITH toInt(row[0]) AS id,
row[1] AS name,
row[2] AS city,
@johnymontana
johnymontana / enron.cypher
Created August 24, 2016 21:17
Import script for Enron emails into Neo4j
CREATE CONSTRAINT ON (u:User) ASSERT u.eid IS UNIQUE;
CREATE CONSTRAINT ON (f:Folder) ASSERT f.name IS UNIQUE;
CREATE CONSTRAINT ON (m:Message) ASSERT m.mid IS UNIQUE;
CREATE INDEX ON :User(email);
LOAD CSV WITH HEADERS FROM "file:///employeelist.csv" AS row
MERGE (u:User {eid: row.eid})
SET u.firstName = row.firstName,
u.lastName = row.lastName,
u.email = row.Email_id;