Skip to content

Instantly share code, notes, and snippets.

View vladbatushkov's full-sized avatar
🥥
Sabai sabai

Vlad Batushkov vladbatushkov

🥥
Sabai sabai
View GitHub Profile
@vladbatushkov
vladbatushkov / External_and_Internal_calls.cypher
Last active August 18, 2019 15:21
Calls between cities and inside
// clean up
MATCH (:City)-[cw:CONNECT_WITH]-(:City)
DELETE cw
// external calls - total
MATCH (c1:City)<-[:FROM]-(:Person)-[]->(c:Call)<-[]-(:Person)-[:FROM]->(c2:City)
WHERE id(c1) > id(c2)
WITH c1.name as from, c2.name as to, count(c) as calls
RETURN sum(calls) as s
@vladbatushkov
vladbatushkov / Degree_Centrality.cypher
Last active August 18, 2019 14:34
Apply Degree Centrality vs calculate it Manualy
// algorithm
CALL algo.degree.stream("City", "CONNECT_WITH", { direction: "both", weightProperty: "calls" }) YIELD nodeId, score
RETURN algo.asNode(nodeId).name AS name, score
ORDER BY score DESC
// manual calculation
MATCH (c:City)-[cw:CONNECT_WITH]-(:City)
RETURN c.name as name, SUM(cw.calls) as score
ORDER BY score DESC
@vladbatushkov
vladbatushkov / Community_Detection.cypher
Last active August 21, 2019 16:36
Community Detection in city
CALL algo.scc(
'MATCH (p:Person)-[:FROM]->(:City { name: "Bangkok" }) RETURN id(p) as id',
'MATCH (p1:Person)-[:OUT]->(:Call)<-[:IN]-(p2:Person) RETURN id(p1) as source, id(p2) as target',
{ write: true, writeProperty: 'communityId', graph:'cypher' })
YIELD communityCount
MATCH (p:Person)-[:FROM]->(:City { name: "Bangkok" })
WITH p.name as name, p.communityId as communityId
RETURN communityId, count(name) as total
ORDER BY total DESC
@vladbatushkov
vladbatushkov / water-planet-v1.js
Last active September 22, 2019 12:58
Example of animation - breathing of water planet
const [scaleValue] = useState(new Animated.Value(1))
const waterAnimation = () => {
Animated.sequence([
Animated.timing(scaleValue, { // 1
toValue: 1.2,
duration: 1500,
easing: Easing.linear
}),
Animated.timing(scaleValue, { // 2
@vladbatushkov
vladbatushkov / Org.cql
Last active November 3, 2019 10:55
Sample of graph
MATCH (n) DETACH DELETE n;
MERGE (org:Organization { name: "StarWars Company", taxid: 111222333 })
MERGE (d0:Department { name: "IT" })
MERGE (d1:Department { name: "Frontend" })
MERGE (d2:Department { name: "DevOps" })
MERGE (d3:Department { name: "Website" })
MERGE (luke:Person { name: "Luke Skywalker" })
MERGE (r2d2:Person { name: "R2D2" })
@vladbatushkov
vladbatushkov / Flights-Workshop-Links.md
Last active November 4, 2019 17:14
Useful links of Neo4j Flights Workshop
@vladbatushkov
vladbatushkov / PathFinding.cql
Created November 4, 2019 15:20
find a path
MATCH p=(a1:Airport { code: "BKK" })-[:FLIES_TO]->(a2:Airport { code: "ARN" })
RETURN p
@vladbatushkov
vladbatushkov / Organizationals.cql
Created November 4, 2019 15:27
Queries to observe Organization structure
MATCH (o:Organization)-[:CONTAINS]->(d:Department)
RETURN *
MATCH (p:Person)-[:WORK_FOR]->(o:Organization)
RETURN *
MATCH (o:Organization)-[:CONTAINS]->(d:Department)-[:LEAD_BY]->(p:Person)
RETURN d, p
MATCH (p:Project)-[:OWNED_BY]->(d:Department)
@vladbatushkov
vladbatushkov / graphql.cql
Created November 4, 2019 17:10
Airline GraphQL schema
CALL graphql.idl("type Airline { code: String! name: String! country: String! }");
CALL graphql.schema();
@vladbatushkov
vladbatushkov / graphql-flights.graphql
Last active November 4, 2019 18:49
GraphQL useful queries
{
Airline(first: 10){
code
name
flights(first: 5) {
flightNumber
}
}
}