Skip to content

Instantly share code, notes, and snippets.

View search.json
{
"file_version": "2.0",
"preferences": {
"custom_engines": {
"ggl": {
"name": "Google Search",
"url": "https://www.google.co.in/search?q={searchTerms}",
"category": "",
"description": "Google Search"
},
@sortega
sortega / connect-status-csv.sh
Created Jan 7, 2021
Export connect status to CSV
View connect-status-csv.sh
#!/bin/bash
CONNECT_URL=${1:-${CONNECT_URL:-http://localhost:8083}}
CONNECTOR_LIST=$(curl -s -L -X GET $CONNECT_URL/connectors | jq -r '.[]')
for CONNECTOR in $CONNECTOR_LIST; do
curl -s -L -X GET $CONNECT_URL/connectors/$CONNECTOR/status \
| jq -r "(.tasks[] | [\"task\", \"$CONNECTOR\", .id, .state, .worker_id]), [\"connector\", \"$CONNECTOR\", .type, .connector.state, .connector.worker_id] | @csv" &
done
wait
@sortega
sortega / pre-commit
Last active Mar 31, 2020
Place this in .git/hooks to avoid commiting malformed terraform sources
View pre-commit
#!/bin/bash
set -e
MODULES=`find . -name '*.tf' -print0 | xargs -0 -n1 dirname | sort --unique | grep -v .terraform`
echo -n "fmt check"
for MODULE in $MODULES; do
(terraform fmt -check && echo -n ".") &
done
wait
echo " OK"
View CodingExercise.scala
package mentoring
object CodingExercise {
final case class Pos(x: Int, y: Int) {
def +(other: Pos) = Pos(x + other.x, y + other.y)
}
object Pos {
val Origin = Pos(0, 0)
}
View ConnectedStreamsApp.scala
object ConnectedStreamsApp extends App {
def writer(outputStream: OutputStream): Unit = {
val writer = new PrintStream(outputStream)
(1 to 1000).foreach { i =>
writer.println(s"line $i")
Thread.sleep(50)
}
writer.close()
}
@sortega
sortega / Json.scala
Last active Aug 22, 2019
Typeclasses sample code
View Json.scala
package fp.typeclasses
import org.apache.commons.text.StringEscapeUtils
sealed abstract class Json
object Json {
type JField = (String, Json)
case object JNull extends Json {
View Day22.scala
package day22
import scalaz._, Scalaz._
object Day22 extends App {
sealed trait Equipment
object Equipment {
case object Climbing extends Equipment
case object Torch extends Equipment
@sortega
sortega / FailFastTraverse.scala
Last active Jan 8, 2018
Future.traverse is not fail fast
View FailFastTraverse.scala
package sandbox.futures
import scala.collection.generic.CanBuildFrom
import scala.concurrent._
import scala.concurrent.duration._
import scala.language.higherKinds
import scala.util.{Random, Success}
import scala.util.control.NoStackTrace
object FailFastTraverse {
@sortega
sortega / Snippet.scala
Created Jun 25, 2017
Some snippet for an explanation
View Snippet.scala
package futures
import scala.concurrent.Future
object Snippet {
type A = String
type B = Int
def first(x: String): Future[Option[A]] = ???
@sortega
sortega / output.sh
Created Mar 23, 2017
Static methods and modules
View output.sh
> ruby statics.rb
4
statics.rb:12:in `<main>': undefined method `non_static' for Foo:Module (NoMethodError)