This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int[][] computeLevenshtein(List<String> wordList, boolean parallel) { | |
final int LIST_SIZE = wordList.size(); | |
int[][] distances = new int[LIST_SIZE][LIST_SIZE]; | |
IntStream range = range(0, LIST_SIZE * LIST_SIZE); | |
if (parallel) { | |
range.parallel(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int[][] computeLevenshteinAugustin(List<String> wordList, boolean parallel) { | |
final int LIST_SIZE = wordList.size(); | |
int[][] distances = new int[LIST_SIZE][LIST_SIZE]; | |
Stream<String> wordStream = wordList.stream(); | |
if (parallel) { | |
wordStream.parallel(); | |
} | |
wordStream.forEach(word -> { | |
int wordIndex = wordList.indexOf(word); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static int[][] computeLevenshteinHector(List<String> wordList, boolean parallel) { | |
final int LIST_SIZE = wordList.size(); | |
int[][] distances = new int[LIST_SIZE][LIST_SIZE]; | |
Stream<String> wordStream = wordList.stream(); | |
if (parallel) { | |
wordStream.parallel(); | |
} | |
distances = wordStream.map(word -> IntStream.range(0, LIST_SIZE) | |
.map(i -> lesson3b.Levenshtein.lev(word, wordList.get(i))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mechanitis.talks.stayingahead; | |
import com.mongodb.DBCollection; | |
import org.mongojack.JacksonDBCollection; | |
import org.mongojack.WriteResult; | |
import javax.ws.rs.core.Response; | |
import java.net.URI; | |
public class BadLambdas { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def xmlSlurper = new XmlSlurper().parse(new File('resources/all-coffee-shops.xml')) | |
xmlSlurper.node.each { child -> | |
Map coffeeShop = ['openStreetMapId': child.@id.text(), | |
'location' : ['coordinates': [Double.valueOf(child.@lon.text()), Double.valueOf(child.@lat.text())], | |
'type' : 'Point']] | |
child.tag.each { theNode -> | |
def fieldName = theNode.@k.text() | |
if (isValidFieldName(fieldName)){ | |
coffeeShop.put(fieldName, theNode.@v.text()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.mongodb.BasicDBObject | |
import com.mongodb.MongoClient | |
def mongoClient = new MongoClient(); | |
def collection = mongoClient.getDB("Cafelito").getCollection("CoffeeShop") | |
collection.drop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collection.remove(new BasicDBObject("address.city", "London")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collection.remove(new BasicDBObject("_id", "jo")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collection.update(query, personDocument, true, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
collection.update(new BasicDBObject(), | |
new BasicDBObject("$set", new BasicDBObject("country", "UK")), false, true); |