Skip to content

Instantly share code, notes, and snippets.

View kbastani's full-sized avatar
💭
Coding

Kenny Bastani kbastani

💭
Coding
View GitHub Profile
-s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin
@kbastani
kbastani / README.md
Last active August 29, 2015 14:05 — forked from mbostock/.block

Unlike choropleth maps, cartograms encode data using area rather than color, resulting in distorted geographic boundaries. In this example, states are rescaled around their centroid, preserving local shape but not topology. Inspired by Zachary Johnson. Non-continguous cartogram design invented by Judy Olsen. U.S. state and county boundaries from the U.S. Census Bureau, simplified using GDAL and MapShaper.

@kbastani
kbastani / TraversalDescriptionByPath
Last active August 29, 2015 14:06
Filter paths by relationship property condition
/*
* Cypher query:
* MATCH p=(michael:Person { name: "Michael" })-[r:LIKES]->(people)
* WHERE r.weight >= 5
* RETURN p
*/
Transaction tx = db.beginTx();
Node michael = db.findNodesByLabelAndProperty(DynamicLabel.label("Person"), "name", "Michael").iterator().next();
@kbastani
kbastani / Configuration.scala
Last active August 29, 2015 14:11
Apache Spark Importer for generating Neo4j batch inserter CSV files from DBPedia RDF dumps
/**
* Copyright (C) 2014 Kenny Bastani
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
@kbastani
kbastani / Grimm TV Ring.md
Created February 17, 2015 09:55
The actor ring for the TV series Grimm
+------------------------------------------------------------------------------------------------------------------------------------------------+
| show                                | cast                                                                                            | people |
+------------------------------------------------------------------------------------------------------------------------------------------------+
| "Cold Case"                         | ["Claire Coffee","Bree Turner","Silas Weir Mitchell (actor)","Bitsie Tulloch","David Giuntoli"] | 5      |
| "CSI: Miami"                        | ["Norberto Barba","Claire Coffee","Sasha Roiz","Silas Weir Mitchell (actor)"]                   | 4      |
| "Law & Order: Special Victims Unit" | ["Kate Burton (actress)","Norberto Barba","Silas Weir Mitchell (actor)","Russell Hornsby"]      | 4      |
| "The West Wing" | ["Marc Buckland","Kate Burton (actress)","Claire Coffee","Bitsie Tulloch"] 
@kbastani
kbastani / monolith.cql
Created May 12, 2015 01:23
Monolithic Graph Data Model Example
// Teams
CREATE (accountsTeam:Team { name: "Accounts team" })
CREATE (inventoryTeam:Team { name: "Inventory team" })
// Services
CREATE (accountingService:Service { name: "Accounting Service"})
CREATE (inventoryService:Service { name: "Inventory Service"})
CREATE (shippingService:Service { name: "Shipping Service"})
// Resources
@kbastani
kbastani / WebConfig.java
Created September 9, 2015 00:33
How to support XML as a Spring WebMvc REST service
@EnableWebMvc
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
messageConverters.add(createXmlHttpMessageConverter());
messageConverters.add(new MappingJackson2HttpMessageConverter());
super.configureMessageConverters(converters);
@kbastani
kbastani / MaximumValueProgam.scala
Last active December 3, 2015 09:41
PregelProgram Abstraction for Spark GraphX
package org.mazerunner.core.programs
import org.apache.spark.graphx.{Graph, EdgeTriplet, VertexId}
import org.mazerunner.core.abstractions.PregelProgram
/**
* @author kbastani
* The [[MaximumValueProgram]] is an example graph algorithm implemented on the [[PregelProgram]]
* abstraction.
*/
@kbastani
kbastani / neo4j-cypher-delete-id-list.txt
Created August 14, 2013 19:06
Follow the steps in this gist to find and delete duplicate nodes on property and index in Neo4j graph database web admin console.
// Delete duplicate nodes as a list collected from the output of neo4j-cypher-duplicate-get-node.txt
START n=node(1120038,1120039,1120040,1120042,1120044,1120048,1120049,1120050,1120053,1120067,1120068)
// Replace IDs above with the IDs from CommaSeparatedListOfIds in neo4j-duplicate-get-node.txt
MATCH n-[r]-()
DELETE r, n
@kbastani
kbastani / CasinoStaff-24-7-Alice.CQL
Last active January 3, 2016 22:39
Casino staff 24/7
// Setup data for casino employee: Alice
WITH { day: 18, month: 1, year: 2014 } as dayMap
// The dayMap field acts as a parameter for this script
// Merge Alice and his skills
MERGE (baccarat:Skill { name: "Baccarat" })
MERGE (blackjack:Skill { name: "Blackjack" })
MERGE (roulette:Skill { name: "Roulette" })
MERGE (alice:Employee { firstname: "Alice", lastname: "Smith" })