Skip to content

Instantly share code, notes, and snippets.

View Brunomachadob's full-sized avatar
🤘

Bruno Brandão Brunomachadob

🤘
View GitHub Profile
@Brunomachadob
Brunomachadob / README.md
Last active September 17, 2018 14:14
Multi threaded access requested by thread Thread[http-nio-8778-exec-1,5,main] but is not allowed for language(s) js

Problem with multi threaded systems on GraalJS

This is an oversimplified example extracted from ThrustJS and it's server lib http to show the result when we try to use Apache Tomcat to serve an API, using Nashorn and GraalJS.

When we navigate to http://localhost:8778/servlet using GraalJS we get an exception:

java.lang.IllegalStateException: Multi threaded access requested by thread Thread[http-nio-8778-exec-1,5,main] but is not allowed for language(s) js.
	com.oracle.truffle.polyglot.PolyglotContextImpl.throwDeniedThreadAccess(PolyglotContextImpl.java:545)
	com.oracle.truffle.polyglot.PolyglotContextImpl.checkAllThreadAccesses(PolyglotContextImpl.java:464)
@Brunomachadob
Brunomachadob / README.md
Last active March 2, 2019 21:36
PDF creators comparison

Research about pdf creation

How to create a PDF file with 15.000 pages, preferably with a Stream as an input and output, to prevent memory issues.

Name Stream Complexity (1-5) Time (s) Memory (mb) O.P. (mb)
[pdfmake] N 2 Infinite 500 None
[pdfkit] Y 5 10 300 None
[pdfjs] Y 3 18 700 None
[wkhtmltopdf] N HTML 83 100 300
@Brunomachadob
Brunomachadob / docker-compose.yml
Last active December 12, 2019 09:24
envoy-request-mirroring
version: '3'
services:
mockserver:
image: jamesdbloom/mockserver:mockserver-4.1.0
command: /opt/mockserver/run_mockserver.sh -serverPort 9090 -Dmockserver.logLevel=WARN
networks:
envoygateway:
aliases:
- api
- api-mirror
data class Request(
val method: String,
val path: String,
val headers: Map<String, String>
)
class RequestBuilder {
private lateinit var method: String
private lateinit var path: String
private var headers = mutableMapOf<String, String>()
@Brunomachadob
Brunomachadob / README.md
Last active May 7, 2020 23:50
Educational-purposed implementation of Diffie Hellman key exchange

This is a educational purposed implementation of the Diffie Hellman key exchange for encrypted conversation between two parties.

Do not use this in production (as it is simplifying a lot of stuff, despite I know you will ignore this)

If you use IntelliJ, you can just paste the implementation into a new scratch and run it.

@Brunomachadob
Brunomachadob / README.md
Last active May 7, 2020 23:52
Educational purposed implementation of a Onion Router (specification of Tor)

This is a educational purposed implementation of the Onion Router specification for encrypted/annonymous conversation between two parties.

Do not use this in production (as it is simplifying a lot of stuff, despite I know you will ignore this)

If you use IntelliJ, you can just paste the implementation into a new scratch and run it.

Let me know in the comments if you have anything that could be improved (without adding too much complexity to it)

@Brunomachadob
Brunomachadob / README.md
Last active October 27, 2020 09:43
Envoy tracing custom_tags modifying x-request-id

Envoy is changing the x-request-id version when we configure the connection manager with:

tracing: {}

I configured Envoy with the upstream cluster pointing to postman-echo.com which will return as response body, the request headers sent.

curl --location --request GET 'localhost:8080/headers' \
--header 'x-request-id: 968ea8f8-3806-45c9-8228-8d3dde5df3b4' \
@Brunomachadob
Brunomachadob / README.md
Last active May 26, 2021 17:20
Proxy with query parameters

Without the right query param:

○ → curl -v localhost:80/mge?serviceName=SessionManagerSP
*   Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 80 (#0)
> GET /mge?serviceName=SessionManagerSP HTTP/1.1
> Host: localhost
> User-Agent: curl/7.64.1