# Creating a lambda
l = lambda { |name| "Hi #{name}!" }
# Executing the lambda
l.call("foo") # => Hi foo!
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 scalaz._ | |
import Scalaz._ | |
def fizzbuzz(i: Int): String = Some("") | |
.mappend(Some("fizz").filter(_ => i % 3 == 0)) | |
.mappend(Some("buzz").filter(_ => i % 5 == 0)) | |
.filter(_.nonEmpty) | |
.getOrElse(i.toString) |
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
//cat ~/.sbt/1.0/plugins/splain.scala 1 ↵ | |
import sbt._ | |
import Keys._ | |
object Splain extends AutoPlugin { | |
override def trigger = allRequirements | |
override def projectSettings = Seq( | |
addCompilerPlugin("io.tryp" % "splain" % "0.3.1" cross CrossVersion.patch) | |
) |
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 $ivy.`io.monix::monix-kafka-1x:1.0.0-RC1` | |
import monix.execution.Scheduler.Implicits.{ global => scheduler } | |
import monix.kafka._ | |
import scala.concurrent.duration._ | |
val producerCfg = KafkaProducerConfig.default.copy( | |
bootstrapServers = List("127.0.0.1:9092") | |
) | |
val producer = KafkaProducer[String,String](producerCfg, scheduler) | |
val messages = scheduler.scheduleWithFixedDelay(1.second, 1.second) { producer.send("test", "hello", s"${System.nanoTime}").runAsync } |
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
# There is no /bin/bash, use shebangs.patch to fix shebangs | |
λ nix-shell -p python2Packages.setuptools_scm -p ansible -p python2Packages.pytest -p python2Packages.pip | |
$ python setup.py egg_info | |
$ COMMIT_MESSAGE="bla" test/utils/shippable/timing.sh test/utils/shippable/shippable.sh "cloud/default/2.7/4" |
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 $ivy.`io.circe::circe-generic:0.8.0` | |
import $ivy.`io.circe::circe-parser:0.8.0` | |
import $ivy.`io.circe::circe-refined:0.8.0` | |
import $ivy.`org.scalaz::scalaz-core:7.2.16` | |
import eu.timepit.refined._ | |
import eu.timepit.refined.api.Refined | |
import eu.timepit.refined.auto._ | |
import eu.timepit.refined.boolean._ | |
import eu.timepit.refined.collection._ |
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
object SwaggerGarbage { | |
val hiddenImplicits = Seq( | |
"AssetRoutes", | |
"AuthenticationDirective", | |
"AuthenticationDirectiveObject", | |
"Authority", | |
"ByteRange", | |
"ByteRanges", | |
"CircuitBreaker", | |
"ClassLoader", |
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
#To Decrypt Jenkins Password from credentials.xml | |
#<username>jenkins</username> | |
#<passphrase>your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J</passphrase> | |
#go to the jenkins url | |
http://jenkins-host/script | |
#In the console paste the script | |
hashed_pw='your-sercret-hash-S0SKVKUuFfUfrY3UhhUC3J' |
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.security.SecureRandom | |
import java.security.cert.{ CertificateException, X509Certificate } | |
import javax.net.ssl.{ HostnameVerifier, SSLContext, SSLSession, X509TrustManager } | |
import scala.util.Try | |
import okhttp3.{ MediaType, OkHttpClient, Request, RequestBody, Response } | |
@SuppressWarnings(Array("org.wartremover.warts.Null")) | |
def getUnsafeClient(): OkHttpClient = { |
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
/** As per [[https://github.com/apache/kafka/blob/0.10.1.1/core/src/main/scala/kafka/common/Topic.scala]] */ | |
type TopicSpec = NonEmpty And MaxSize[W.`249`.T] And MatchesRegex[W.`"[a-zA-Z0-9\\\\.\\\\-_]+"`.T] And Not[Equal[W.`"."`.T]] And Not[Equal[W.`".."`.T]] |
NewerOlder