Skip to content

Instantly share code, notes, and snippets.

@diogoaurelio
diogoaurelio / emr_boto3_example.py
Last active November 23, 2017 13:24
emr_boto3_example.py
applications = [
{'Name': 'Spark'},
{'Name': 'Hive'},
{'Name': 'Tez'},
{'Name': 'Hadoop'},
{'Name': 'Ganglia'},
{'Name': 'Presto'},
{'Name': 'Zeppelin'}
]
release_label = "emr-5.9.0"
class Country:
"""
Convenience class for storing
data relative to a given country
"""
def __init__(self, country_name, population, continent):
"""
Default constructor
:param country_name: str
import tensorflow as tf
import numpy as np
# Start by creating random values:
x_data = np.random.rand(100).astype(np.float32)
_y_data = 3 + 5 * x_data
y_data = np.vectorize(lambda y: y + np.random.normal(loc=0.0, scale=0.1))(_y_data)
# ... and then initializing the variables a and b, with any random guess,
import tensorflow as tf
x = tf.Variable(3, name="x", dtype=tf.int16)
y = tf.Variable(4, name="y", dtype=tf.int16)
a = tf.constant(5, dtype=tf.int16)
b = tf.constant(10, dtype=tf.int16)
c = tf.constant(15, dtype=tf.int16)
op1 = x*x*y
import tensorflow as tf
x = tf.Variable(3, name="x", dtype=tf.int16)
y = tf.Variable(4, name="y", dtype=tf.int16)
a = tf.constant(5, dtype=tf.int16)
b = tf.constant(10, dtype=tf.int16)
c = tf.constant(15, dtype=tf.int16)
op1 = x*x*y
import tensorflow as tf
a = tf.constant(1)
b = tf.constant(2)
c = a + b
with tf.Session() as session:
result = session.run(c)
print("Tensorflow supports simple summation with op: 'a + b = {}'".format(result))
# Tensorflow supports simple summation with op: a + b = 3
import java.util.concurrent.TimeUnit
import akka.actor.{Actor, ActorSystem, Props}
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import akka.event.{Logging, LoggingAdapter}
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.server.Directives._
import akka.stream.Materializer
import akka.stream.scaladsl.{Flow, Sink, Source}
import com.typesafe.config.Config
import com.typesafe.config.ConfigFactory
import scala.concurrent.{ExecutionContextExecutor, Future}
import spray.json.DefaultJsonProtocol
import com.ning.http.client.{AsyncHttpClientConfigBean, AsyncHttpClientConfig}
import play.api.libs.ws.ning.NingWSClient
import play.api.libs.ws.ning.NingAsyncHttpClientConfigBuilder
import play.api.libs.ws.ssl.{SSLLooseConfig, SSLConfig}
import play.api.libs.ws.{WSClientConfig, DefaultWSClientConfig, WSResponse}
import scala.concurrent.{ExecutionContext, Future}
import play.api.libs.json._
trait PlayWsRequester {
import scalaj.http._
import scala.concurrent.{ExecutionContext, Future}
/**
* Trait for generic scalaj HTTP requests
*
*/
trait ScalaJHttpRequester {
def getRequest(address:String,