Skip to content

Instantly share code, notes, and snippets.

View mukel's full-sized avatar
Espresso

Alfonso² Peterssen mukel

Espresso
View GitHub Profile
@mukel
mukel / JSON.java
Last active November 22, 2024 20:27
A lightweight JSON parser and printer utility class.
import java.util.*;
/**
* A lightweight JSON parser and printer utility class.
* This class provides functionality to parse JSON strings into Java objects and
* convert Java objects back to JSON strings.
*
* <p>The parser supports all standard JSON data types:
* <ul>
* <li>Objects ({@code Map<String, Object>})</li>
@mukel
mukel / LangChain4jDemo.java
Created November 11, 2024 10:04
Simple Llama3.java integration demo with LangChain4j
///usr/bin/env jbang "$0" "$@" ; exit $?
//JAVA 21+
//PREVIEW
//COMPILE_OPTIONS --add-modules=jdk.incubator.vector
//RUNTIME_OPTIONS --add-modules=jdk.incubator.vector
//DEPS dev.langchain4j:langchain4j:0.35.0
//SOURCES https://github.com/mukel/llama3.java/blob/main/Llama3.java
@mukel
mukel / DynamicJava.java
Created June 14, 2021 20:45
Compiling Java code dynamically and running it in Espresso.
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Value;
@mukel
mukel / ScalajHttpClient.scala
Created August 17, 2017 21:42
scalaj-http client for TelegramBot4s
package info.mukel.telegrambot4s.client
import java.nio.file.Files
import info.mukel.telegrambot4s.api.RequestHandler
import info.mukel.telegrambot4s.marshalling.JsonMarshallers
import info.mukel.telegrambot4s.methods.{ApiRequest, ApiRequestJson, ApiRequestMultipart, ApiResponse}
import info.mukel.telegrambot4s.models.InputFile
import scala.concurrent.{ExecutionContext, Future}
package info.mukel.telegrambot4s.examples
import akka.actor.{Actor, ActorRef, Props, Terminated}
import info.mukel.telegrambot4s.actors.{ActorDispatcher}
import info.mukel.telegrambot4s.api.{AkkaDefaults, Commands, Polling}
import info.mukel.telegrambot4s.models.{Message, Update}
class ActorBot(token: String) extends TestBot(token) with Polling with Commands with PerChatDispatcher {
on("/hello") { implicit msg => _ =>
reply("Hello World!")
IntRRBVector(0 until /*32^5*/33554432 : _*).foreach(_ => ()) // OK
IntRRBVector(0 until /*32^5 + 1*/33554433 : _*).foreach(_ => ()) // ClassCastException
IntRRBVector(0 until /*32^5 + 1*/33554433 : _*).apply(1024) // NPE
// https://github.com/nicolasstucki/scala-rrb-vector
RRBVector.fill(/*32^5*/33554432)(0).foreach(_ => ()) // OK
RRBVector.fill(/*32^5 + 1*/ 33554433)(0).apply(1024) // NPE
RRBVector.fill(/*32^5 + 1*/33554433)(0).foreach(_ => ()) // ClassCastException