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 akka.actor.{ Actor, ActorSystem, Props } | |
import scala.concurrent.duration._ | |
class HelloActor extends Actor { | |
def receive = { | |
case "exit" => context.system.shutdown() | |
case message => println(message) | |
} | |
} |
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.cloud9ers.play2.sockjs | |
import java.text.SimpleDateFormat | |
import java.util.Date | |
import scala.Option.option2Iterable | |
import scala.concurrent.Future | |
import scala.concurrent.duration.DurationInt | |
import scala.util.Random | |
import com.cloud9ers.play2.sockjs.transports.{ EventSourceTransport, JsonPTransport, Transport, WebSocketTransport, XhrTransport } | |
import akka.actor.{ ActorRef, actorRef2Scala } |
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.cloud9ers.play2.sockjs.transports | |
import scala.Array.canBuildFrom | |
import scala.concurrent.Promise | |
import scala.concurrent.duration.DurationInt | |
import org.codehaus.jackson.JsonParseException | |
import com.cloud9ers.play2.sockjs.{ JsonCodec, Session, SockJsFrames } | |
import akka.actor.{ ActorRef, PoisonPill, Props, actorRef2Scala } | |
import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
import play.api.libs.iteratee.Concurrent |
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
# Partition the following data into 2 lists: males and females | |
users = [{ | |
"name": "user_%s" % x, | |
"gender": 'f' if x % 3 is random.randint(0,3) else 'm' | |
} | |
for x in range(1, 100)] | |
# Which way do you prefer? | |
# 1 |
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 org.deeplearning4j.nn.conf.NeuralNetConfiguration; | |
import org.deeplearning4j.nn.conf.layers.RBM; | |
import org.deeplearning4j.nn.weights.WeightInit; | |
import org.deeplearning4j.nn.conf.distribution.UniformDistribution; | |
import org.deeplearning4j.nn.api.OptimizationAlgorithm; | |
import org.nd4j.linalg.lossfunctions.LossFunctions; | |
import org.deeplearning4j.nn.conf.`override`.ClassifierOverride; | |
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork; | |
import org.deeplearning4j.optimize.listeners.ScoreIterationListener; | |
import org.deeplearning4j.optimize.api.IterationListener; |
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 exampels | |
import com.datastax.spark.connector.cql.CassandraConnector | |
import org.apache.spark.{ SparkConf, SparkContext } | |
import org.apache.spark.sql.cassandra.CassandraSQLContext | |
import org.apache.spark.SparkContext._ | |
import com.datastax.spark.connector._ | |
object CassandraSparkExamples { | |
// Connection |
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 sys | |
import signal | |
def signal_handler(sig, frame): | |
print(f"EMERGENCY LANDING BY USER!") | |
scf.cf.commander.send_setpoint(0, 0, 0, 0) | |
sys.exit(0) |
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
PROMPT='$(kube_ps1) '$PROMPT |
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 consumeFromKafka(topic: String) = { | |
val props = new Properties() | |
props.put("bootstrap.servers", "localhost:9094") | |
props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer") | |
props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer") | |
props.put("auto.offset.reset", "latest") | |
props.put("group.id", "consumer-group") | |
val consumer: KafkaConsumer[String, String] = new KafkaConsumer[String, String](props) | |
consumer.subscribe(util.Arrays.asList(topic)) | |
while (true) { |
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 java.time.Duration | |
import java.util.{Collections, Properties} | |
import cats.effect.{IO, Resource, Timer} | |
import org.apache.kafka.clients.consumer.{KafkaConsumer, ConsumerConfig => KafkaConsumerConfig} | |
import org.apache.kafka.common.serialization.StringDeserializer | |
import scala.collection.JavaConverters._ | |
import scala.concurrent.ExecutionContext |
OlderNewer