Skip to content

Instantly share code, notes, and snippets.

View freeeve's full-sized avatar

Eve Freeman freeeve

  • Fairfax, VA
View GitHub Profile

My First GraphGist

Neo4j:

neo4j logo 2015
CREATE (p:Person {name:"I"})-[:LIKES]->(neo:Database {name:"Neo4j"})
package main
import (
"encoding/json"
"fmt"
"net/http"
)
type Person struct {
Name string
This file has been truncated, but you can view the full file.
a cappella,4,A214
a fortiori,5,A163
a gogo,3,A200
a posteriori,6,A123
a priori,4,A160
a tempo,3,A351
a-plenty,3,A145
aardvark,2,A631
aardwolf,2,A634
absinth,2,A125
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
package main
import "fmt"
// 0 1 2 3 4 5 6 7 - indexes
// 8 10 8 6 8 8 11 9 - array (input)
// 1 5 4 1 2 1 -1 -1 - differences (desired result)
var arr = []int{8, 10, 8, 6, 8, 8, 11, 9} // - array (input)
type pair struct {
package main
import "fmt"
var arr = []int{1, 7, 3, 4}
var ans = []int{84, 12, 28, 21}
func main() {
res := make([]int, len(arr))
for i, _ := range res {
eve-macbook.local:algo go run rotation.go
min: 0 mid: 0 max: 10 lowest: ptolemaic highest: othellolagkage
min: 0 mid: 5 max: 6 lowest: ptolemaic highest: asymptote
min: 2 mid: 3 max: 6 lowest: undulate highest: asymptote
returning asymptote
5
@freeeve
freeeve / batch-import.txt
Last active March 4, 2017 22:25
load csv, neo4j-import, custom batchinserter
- LOAD CSV (Cypher): <10M nodes
- https://gist.github.com/freeeve/89c753f0ad5887949023
- https://github.com/mneedham/graphconnect-training
- https://www.airpair.com/neo4j/posts/getting-started-with-neo4j-and-cypher
- bin/neo4j-import (neo4j 2.2+)
- http://neo4j.com/developer/guide-import-csv/#_super_fast_batch_importer_for_huge_datasets
- implement BatchInserter API (custom, RDF, etc.)
- https://github.com/elegantcoding/Freebase2Neo
- http://neo4j.com/docs/stable/batchinsert-examples.html
#!/usr/bin/env bash
SCM_THEME_PROMPT_PREFIX="${cyan}(${green}"
SCM_THEME_PROMPT_SUFFIX="${cyan})"
SCM_THEME_PROMPT_DIRTY=" ${red}✗"
SCM_THEME_PROMPT_CLEAN=" ${green}✓"
prompt() {
PS1="$(scm_prompt_info)${reset_color} ${cyan}`hostname`:\W${reset_color} "
}
LOAD CSV WITH HEADERS FROM 'http://www4.skeweredrook.com/movies.csv' as record
WITH toInt(record.movieId) as movieId, record.title as title, toFloat(record.voteAverage) as avgVote, toInt(record.releaseYear) as releaseYear,
record.tagline as tagline, split(record.genres, ":") as genres, toInt(record.personId) as personId, record.name as personName,
toInt(record.birthYear) as birthYear, toInt(record.deathYear) as deathYear, split(record.characters, ":") as roles,
CASE WHEN record.personType = "ACTOR" THEN [1] ELSE [] END as actor, CASE WHEN record.personType = "DIRECTOR" THEN [1] ELSE [] END as director
MERGE (movie:Movie {id:movieId})
ON CREATE SET movie.title = title, movie.avgVote = avgVote, movie.releaseYear = releaseYear, movie.tagline = tagline, movie.genres = genres
FOREACH(x in actor | MERGE(person:Person {id:personId})
ON CREATE SET person.name = personName, person.born = birthYear, person.died = case when deathYear > 0 then deathYear else null end
MERGE (person)-[:ACTED_IN {roles:roles}]->(movie))