Skip to content

Instantly share code, notes, and snippets.

View NeQuissimus's full-sized avatar
:octocat:
This is my status

Tim Steinbach NeQuissimus

:octocat:
This is my status
View GitHub Profile
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)
@NeQuissimus
NeQuissimus / splain.scala
Created May 31, 2018 00:49
Global splain
//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)
)
@NeQuissimus
NeQuissimus / ammonite.scala
Created April 28, 2018 23:52
Generate Kafka sample messages
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 }
@NeQuissimus
NeQuissimus / run.sh
Last active April 20, 2018 02:20
Run Ansible tests on NixOS
# 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"
@NeQuissimus
NeQuissimus / test.scala
Last active October 17, 2017 23:22
circe + refined
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._
@NeQuissimus
NeQuissimus / unwantedDefinitions.scala
Created August 2, 2017 18:26
override val unwantedDefinitions = SwaggerGarbage.hiddenImplicits for your SwaggerHttpService
object SwaggerGarbage {
val hiddenImplicits = Seq(
"AssetRoutes",
"AuthenticationDirective",
"AuthenticationDirectiveObject",
"Authority",
"ByteRange",
"ByteRanges",
"CircuitBreaker",
"ClassLoader",
@NeQuissimus
NeQuissimus / jenkins-decrypt.groovy
Created July 6, 2017 14:35 — forked from tuxfight3r/jenkins-decrypt.groovy
Decrypting Jenkins Password
#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'
@NeQuissimus
NeQuissimus / okhttp_unsafe.scala
Created April 6, 2017 19:02
OkHttp client that ignores SSL certificate verification (for testing)
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 = {
/** 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]]
@NeQuissimus
NeQuissimus / Ruby Lambdas.md
Created November 27, 2016 20:37 — forked from Integralist/Ruby Lambdas.md
Ruby lambdas

Lambda: standard

# Creating a lambda
l = lambda { |name| "Hi #{name}!" }

# Executing the lambda
l.call("foo") # => Hi foo!