Skip to content

Instantly share code, notes, and snippets.

View dainiusjocas's full-sized avatar
:octocat:
editing status

Dainius Jocas dainiusjocas

:octocat:
editing status
View GitHub Profile
@dainiusjocas
dainiusjocas / kc-failed20200721.json
Created July 21, 2020 16:03
kafka connect failure
{
"name": "core-xx5-core-items",
"connector": {
"state": "RUNNING",
"worker_id": "10.35.1.9:8088"
},
"tasks": [
{
"id": 0,
"state": "RUNNING",
@dainiusjocas
dainiusjocas / uuid.sh
Created June 8, 2020 12:09
Babashka generate UUID
#!/bin/sh
bb -e '(import java.util.UUID)(str (UUID/randomUUID))'
@dainiusjocas
dainiusjocas / bang-kafka-rest-proxy-with-ab.md
Created May 13, 2020 10:17
Kafka REST Proxy throughput test

contents of the request.json file

{
  "records": [
    {
      "value": {"prop": "value"},
      "key": "key"
    }
  ]
}
@dainiusjocas
dainiusjocas / kafka_delete_topics.sh
Created May 4, 2020 09:10
Delete kafka topics by pattern
./bin/kafka-topics.sh --zookeeper localhost:2181 --list | grep my_pattern | while read topic; do ./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic $topic; done
# HELP kafka_connect_connector_state_running is the connector running?
# TYPE kafka_connect_connector_state_running gauge
kafka_connect_connector_state_running{connector="CONNECTOR_20200417105809",state="paused",worker="connect:8088"} 0
# HELP kafka_connect_connector_tasks_state the state of tasks. 0-failed, 1-running, 2-unassigned, 3-paused
# TYPE kafka_connect_connector_tasks_state gauge
kafka_connect_connector_tasks_state{connector="CONNECTOR_20200417105809",id="0",state="paused",worker_id="connect:8088"} 3
kafka_connect_connector_tasks_state{connector="CONNECTOR_20200417105809",id="1",state="paused",worker_id="connect:8088"} 3
kafka_connect_connector_tasks_state{connector="CONNECTOR_20200417105809",id="10",state="paused",worker_id="connect:8088"} 3
kafka_connect_connector_tasks_state{connector="CONNECTOR_20200417105809",id="11",state="paused",worker_id="connect:8088"} 3
kafka_connect_connector_tasks_state{connector="CONNECTOR_20200417105809",id="12",state="paused",worker_id="connect:8088"} 3
@dainiusjocas
dainiusjocas / curl-parse.clj
Last active March 22, 2020 21:30
Function to parse curl response with headers to a map
(defn resp->map [resp]
(let [lines (str/split resp #"\r\n")
status (Integer/parseInt (second (str/split (first lines) #" ")))
headers (reduce (fn [acc header-line]
(let [[k v] (str/split header-line #":" 2)]
(assoc acc (str/lower-case k) (str/trim v))))
{}
(remove str/blank? (drop-last (rest lines))))]
{:body (last lines)
:status status
@dainiusjocas
dainiusjocas / babashka.log
Created March 21, 2020 22:43
Babashka error
Util_sun_misc_Signal.ensureInitialized: CSunMiscSignal.create() failed. errno: 38 Function not implemented
Fatal error: Util_sun_misc_Signal.ensureInitialized: CSunMiscSignal.open() failed.
JavaFrameAnchor dump:
No anchors
TopFrame info:
TotalFrameSize in CodeInfoTable 32
VMThreads info:
VMThread 0000000003042750 STATUS_IN_JAVA (safepoints disabled) java.lang.Thread@0x264fa98
VM Thread State for current thread 0000000003042750:
0 (8 bytes): com.oracle.svm.jni.JNIThreadLocalEnvironment.jniFunctions = (bytes)
@dainiusjocas
dainiusjocas / compile.clj
Created November 12, 2019 17:47
Clojure script to AOT compile namespaces
#!/usr/bin/env bash
"exec" "clojure" "-Sdeps" "{:deps {org.clojure/tools.namespace {:mvn/version \"0.3.1\"}}}" "$0" "$@"
"USAGE: ./compile.clj"
(require
'[clojure.edn :as edn]
'[clojure.java.io :as io]
'[clojure.string :as str]
@dainiusjocas
dainiusjocas / script.sh
Last active July 20, 2022 05:16
Run Duckling on Ubuntu
stack exec duckling-example-exe
@dainiusjocas
dainiusjocas / log.clj
Created October 13, 2019 12:25
Clojure logging
; When you don't want to add logging library and you want to `(log/spy )` to work
```clojure
(let [r (.getLogger (LogManager/getLogManager) "")]
(.setLevel r Level/FINE)
(doseq [h (.getHandlers r)]
(.setLevel h Level/FINE)))
=> nil
(log/spy :debug (+ 1 1))
Oct 13, 2019 3:23:06 PM clojure.tools.logging$eval1251$fn__1254 invoke