Skip to content

Instantly share code, notes, and snippets.

@jimmycrequer
jimmycrequer / guessCountryFromNeighbors.js
Created November 30, 2019 07:34
geography-guessCountryFromNeighbors
async function guessCountryFromNeighbors() {
await session
.run(`
MATCH (c:Country)-[:IS_NEIGHBOR_OF]-(n:Country)
WITH c.name AS country, collect(n.name) AS neighbors
RETURN country, neighbors
`)
.then(res => {
const i = Math.round(Math.random() * res.records.length - 1)
@jimmycrequer
jimmycrequer / guessCountryFromCapital.js
Created November 30, 2019 07:32
geography-guesscontryfromcapital
async function guessCountryFromCapital() {
await session
.run(`
MATCH p = (:Country)<-[:IS_CAPITAL_OF]-(:City)
RETURN apoc.coll.randomItem(collect(p)) AS p
`)
.then(res => {
const p = res.records[0].get('p')
const capitalName = p.end.properties.name
const countryName = p.start.properties.name
@jimmycrequer
jimmycrequer / main.js
Created November 30, 2019 07:31
geography-main.js
const neo4j = require('neo4j-driver').v1
const readlineSync = require('readline-sync')
let driver, session
async function main() {
driver = neo4j.driver(
'bolt://localhost',
neo4j.auth.basic('neo4j', 'letmein')
)
@jimmycrequer
jimmycrequer / countries.json
Last active November 30, 2019 07:34
geography-graph
[
{
"name": "Russia",
"population": 144526636,
"area": 17098242,
"capital": "Moscow",
"neighbors": ["Azerbaijan", "Belarus", "Estonia", "Finland", "Georgia", "Kazakhstan", "Latvia", "Lithuania", "Norway", "Poland", "Ukraine"]
},
{
"name": "Germany",
LOAD CSV FROM "https://gist.githubusercontent.com/jimmycrequer/44b00d26ed1ec69c24c5107146de56c8/raw/a7ce1c5f4424f79299ceae5f6dc8110a348cf4de/worlds2019-picksbans.csv" AS row
MERGE (blue:Team {name: row[0]})
MERGE (red:Team {name: row[1]})
MERGE (bb1:Champion {name: row[2]})
CREATE (blue)-[:BANNED]->(bb1)
MERGE (bb2:Champion {name: row[3]})
CREATE (blue)-[:BANNED]->(bb2)
MERGE (bb3:Champion {name: row[4]})
CREATE (blue)-[:BANNED]->(bb3)
<template>
<div class="wrapper" :class="level">
<slot></slot>
<span class="right"><slot name="button"></slot></span>
</div>
</template>
<script>
export default {
<alert>Something went wrong.</alert>
<template>
<div class="wrapper" :class="level">
<slot></slot>
</div>
</template>
<script>
export default {
props: {
level: { type: String, default: 'error' }