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 graphql.GraphQL; | |
import graphql.Scalars; | |
import graphql.schema.DataFetcher; | |
import graphql.schema.DataFetchingEnvironment; | |
import graphql.schema.GraphQLSchema; | |
import static graphql.schema.FieldCoordinates.coordinates; | |
import static graphql.schema.GraphQLArgument.newArgument; | |
import static graphql.schema.GraphQLCodeRegistry.newCodeRegistry; | |
import static graphql.schema.GraphQLFieldDefinition.newFieldDefinition; |
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
#!/bin/bash | |
# git-standup: find out what you did yesterday (or last friday). | |
# | |
# Setup: | |
# 1. Change AUTHOR if your git user doesn't match your unix account. | |
# 2. Save somewhere on your path, make executable. | |
# 3. git config --global alias.standup '!git-standup' | |
# 4. Profit. | |
# | |
# Original idea via @paulgreg (https://twitter.com/paulgreg/status/248686055727972352) |
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
// (in src/main/scala/example/) | |
package example | |
import com.datastax.oss.driver.api.core.cql.BatchType | |
import com.datastax.driver.dse.DseCluster | |
object Hello extends App { | |
// Test if JAVA-2365 creates a problem: | |
println(BatchType.LOGGED) |
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.datastax.oss.driver.mapper; | |
import static com.datastax.oss.driver.api.querybuilder.QueryBuilder.bindMarker; | |
import com.datastax.oss.driver.api.core.CqlSession; | |
import com.datastax.oss.driver.api.core.cql.BatchStatement; | |
import com.datastax.oss.driver.api.core.cql.BatchStatementBuilder; | |
import com.datastax.oss.driver.api.core.cql.BoundStatementBuilder; | |
import com.datastax.oss.driver.api.core.cql.DefaultBatchType; | |
import com.datastax.oss.driver.api.core.cql.PreparedStatement; |
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 static ch.qos.logback.classic.Level.ALL; | |
import static org.slf4j.Logger.ROOT_LOGGER_NAME; | |
import java.io.ByteArrayOutputStream; | |
import java.io.OutputStream; | |
import java.io.UnsupportedEncodingException; | |
import java.nio.charset.Charset; | |
import ch.qos.logback.classic.Level; | |
import ch.qos.logback.classic.Logger; |
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.datastax.driver.core.Cluster; | |
import com.datastax.driver.core.PreparedStatement; | |
import com.datastax.driver.core.Row; | |
import com.datastax.driver.core.Session; | |
import java.nio.ByteBuffer; | |
import java.util.concurrent.TimeUnit; | |
public class Read2MbBlobs { | |
public static void main(String[] args) { |
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.datastax.driver.core.*; | |
import com.datastax.driver.core.exceptions.InvalidTypeException; | |
import java.nio.ByteBuffer; | |
public class LongToDateDemo { | |
public static class LongToDateCodec extends TypeCodec<Integer> { | |
// Piggyback on the default codecs' implementation |
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.datastax.driver.core.*; | |
import com.datastax.driver.core.policies.Policies; | |
import java.net.InetAddress; | |
public class GatherAllListenAddresses { | |
public static void main(String[] args) { | |
Cluster cluster = null; | |
try { | |
cluster = Cluster.builder() |
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
// Naive solution (two passes) | |
def volume(l: List[Int]) = { | |
def peakRight(l: List[Int]) = l.foldRight(List(0)) { case (i, acc) => (i max acc.head) :: acc }.tail | |
def peakLeft(l: List[Int]) = peakRight(l.reverse).reverse | |
val waterLevels = peakLeft(l) zip peakRight(l) map { case (l, r) => l min r } | |
val volumes = l zip waterLevels map { case (g, w) => (w - g) max 0 } | |
volumes reduceLeft (_ + _) | |
} |
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 scala.concurrent.Future | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.util.{Try, Success, Failure} | |
val f: Future[Int] = Future(1 / 0) | |
// answer C | |
def applyC[T](f: Future[T]): Future[Try[T]] = f.map(x => Try(x)) | |
// answer D |
NewerOlder