Skip to content

Instantly share code, notes, and snippets.

View arnaudgeiser's full-sized avatar

Arnaud Geiser arnaudgeiser

View GitHub Profile
❯ python3 consume.py
INFO:kafka.consumer.subscription_state:Updating subscribed topics to: ('demo-topic2',)
Start consuming
INFO:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=test-exoscale-08c3c08f-8fb6-4b9c-b7d9-104509cfeb05.aivencloud.com:21701 <connecting> [IPv4 ('91.92.117.22', 21701)]>: connecting to test-exoscale-08c3c08f-8fb6-4b9c-b7d9-104509cfeb05.aivencloud.com:21701 [('91.92.117.22', 21701) IPv4]
INFO:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=test-exoscale-08c3c08f-8fb6-4b9c-b7d9-104509cfeb05.aivencloud.com:21701 <handshake> [IPv4 ('91.92.117.22', 21701)]>: Loading SSL CA from /home/arnaudgeiser/ca.pem
INFO:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=test-exoscale-08c3c08f-8fb6-4b9c-b7d9-104509cfeb05.aivencloud.com:21701 <handshake> [IPv4 ('91.92.117.22', 21701)]>: Loading SSL Cert from /home/arnaudgeiser/test-kafka_cert.pem
INFO:kafka.conn:<BrokerConnection node_id=bootstrap-0 host=test-exoscale-08c3c08f-8fb6-4b9c-b7d9-104509cfeb05.aivencloud.com:21701 <handshake> [IPv
❯ mvn test
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for ch.hearc:projet-cafheg-mykeli:war:1.0-SNAPSHOT
[WARNING] 'dependencies.dependency.version' for org.junit.jupiter:junit-jupiter:jar is either LATEST or RELEASE (both of them are being deprecated) @ org.example:workshop-fp:1.0-SNAPSHOT, /home/arnaudgeiser/temp/pom.xml, line 25, column 16
[WARNING] 'parent.relativePath' of POM ch.hearc:projet-cafheg-mykeli:1.0-SNAPSHOT (/home/arnaudgeiser/temp/projet-cafheg-mykeli/pom.xml) points at org.example:workshop-fp instead of org.springframework.boot:spring-boot-starter-parent, please verify your project structure @ line 15, column 13
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
Compiling 5 source files to /home/arnaudgeiser/code/aleph/target/classes
warning: [options] bootstrap class path not set in conjunction with -source 8
1 warning
Reflection warning, /tmp/form-init974355719809278585.clj:1:9585 - reference to field deleteOnExit can't be resolved.
nREPL server started on port 45361 on host localhost - nrepl://localhost:45361
;; Connected to nREPL server - nrepl://localhost:45361
;; CIDER 1.3.0 (Ukraine), nREPL 0.9.0
;; Clojure 1.11.0, Java 17.0.4.1
;; Docs: (doc function-name)
;; (find-doc part-of-name)
(require '[next.jdbc :as jdbc])
(import '[org.dbunit.database DatabaseConnection QueryDataSet])
(import '[org.dbunit.dataset.xml FlatXmlDataSet])
(let [db-conn (DatabaseConnection. (jdbc/get-connection db-spec))
dataset (QueryDataSet. db-conn)]
(.addTable dataset "RESTAURANTS" "SELECT * FROM Restaurants")
(.addTable dataset "LIKES" "SELECT * FROM Likes WHERE FK_REST IN (SELECT NUMERO FROM Restaurants)")
(.addTable dataset "COMMENTAIRES" "SELECT * FROM Commentaires WHERE FK_REST IN (SELECT NUMERO FROM Restaurants)")
(.addTable dataset "NOTES" "SELECT * FROM Notes WHERE fk_comm IN (SELECT NUMERO FROM Commentaires WHERE FK_REST IN (SELECT NUMERO FROM Restaurants))")
@arnaudgeiser
arnaudgeiser / export.clj
Last active March 13, 2023 17:41
export.clj
(require '[clojure.java.io :as io])
(require '[clojure.data.xml :as xml])
(require '[next.jdbc.sql :as sql])
(require '[next.jdbc.result-set :as rs])
(def db-spec
"Database connection"
{:dbtype "oracle:thin"
:host "localhost"
:user "system"
@arnaudgeiser
arnaudgeiser / sse.clj
Last active January 27, 2023 22:44
Server Sent Events
(defn- streaming-handler
[_]
(let [body (s/stream)]
(future
(dotimes [i 10]
(s/put! body (format "data: %s \n\n" i))
(Thread/sleep 200))
(s/close! body))
{:status 200
:headers {"Content-Type" "text/event-stream"}
❯ curl -v -s -H "Cookie: session=<REDACTED> https://adventofcode.com/2022/day/2/input 2>&1 | head -100
* Trying 3.94.124.104:443...
* Connected to adventofcode.com (3.94.124.104) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
* CAfile: /etc/ssl/certs/ca-certificates.crt
* CApath: /etc/ssl/certs
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
@arnaudgeiser
arnaudgeiser / gist:fba6d60a3daf37f162462d3449fcdc9a
Last active April 27, 2022 12:26
Aleph vs Donkey vs Reitit
## Aleph
{
"fortune": {},
"plaintext": {
"aleph": [
{
"latencyAvg": "9.26ms",
"latencyMax": "83.60ms",
"latencyStdev": "7.71ms",
"totalRequests": 5288692,
@arnaudgeiser
arnaudgeiser / AJavaFile.java
Created April 11, 2022 12:06
Maps and classes
class Etudiant {
public final String nom;
public final String prenom;
public final double note1;
public final double note2;
public final double note3;
public Etudiant(String nom, String prenom, double note1, double note2, double note3) {
this.nom = nom;
this.prenom = prenom;
public class OrderService {
private final EmailService emailService;
public OrderService(EmailService emailService) {
this.emailService = emailService;
}
public void createOrder(Order order) {
// ...
emailService.send(email)