Skip to content

Instantly share code, notes, and snippets.

View quanticc's full-sized avatar
👽
>:]

Ivan Abarca quanticc

👽
>:]
View GitHub Profile
/*
* This file is part of Discord4J.
*
* Discord4J is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Discord4J is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@quanticc
quanticc / RateLimiter.java
Created September 1, 2019 08:48
A single file rate limiter in Java.
/*
* Copyright 2016-2019 Robert Winkler and Bohdan Storozhuk
* Copyright 2019 Volkan Yazici
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
@Test
public void monadicFold() {
Mono<String> reduced = countEvenOdd(Flux.range(1, 10));
StepVerifier.create(reduced)
.expectNext("Evens=5, Odds=5")
.verifyComplete();
reduced = countEvenOdd(Flux.just(1, 3, 5, 7, 9, 10, 12, 14));
Failed to execute org.gradle.cache.internal.AsyncCacheAccessDecoratedCache$2@7593d757.
org.gradle.api.UncheckedIOException: java.io.IOException: Invalid argument
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:61)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:41)
at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.doWriteAction(DefaultFileLockManager.java:210)
at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.writeFile(DefaultFileLockManager.java:197)
at org.gradle.cache.internal.DefaultCacheAccess$UnitOfWorkFileAccess.writeFile(DefaultCacheAccess.java:412)
at org.gradle.cache.internal.DefaultMultiProcessSafePersistentIndexedCache.put(DefaultMultiProcessSafePersistentIndexedCache.java:70)
at org.gradle.cache.internal.AsyncCacheAccessDecoratedCache$2.run(AsyncCacheAccessDecoratedCache.java:64)
at org.gradle.internal.concurren
/*
* This file is part of Discord4J.
*
* Discord4J is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Discord4J is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
@quanticc
quanticc / patch.diff
Last active February 10, 2017 02:20
Dispose WebSocketClient on reconnect while keeping the HttpClient and its internal QueuedThreadPool alive
diff --git a/src/main/java/sx/blah/discord/api/internal/DiscordWS.java b/src/main/java/sx/blah/discord/api/internal/DiscordWS.java
index 71645a20..2233ef56 100644
--- a/src/main/java/sx/blah/discord/api/internal/DiscordWS.java
+++ b/src/main/java/sx/blah/discord/api/internal/DiscordWS.java
@@ -2,6 +2,7 @@ package sx.blah.discord.api.internal;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.util.ssl.SslContextFactory;
@quanticc
quanticc / Case not covered in #205
Last active January 25, 2017 19:33
Logout issue with CTRL+C
2017-01-25 08:47:29.520 INFO 2948 --- [t@1688183524-41] sx.blah.discord.Discord4J : Shard 0 websocket disconnected with status code 1006 and reason "WebSocket Read EOF".

Keybase proof

I hereby claim:

  • I am quanticc on github.
  • I am iab (https://keybase.io/iab) on keybase.
  • I have a public key whose fingerprint is 49D3 6341 C4E4 50E0 BDB3 D5C4 A2DB 2ACB 0569 33AA

To claim this, I am signing this object:

@quanticc
quanticc / YouTube.java
Last active June 4, 2018 23:14
Example for YouTube and Discord4J, needs youtube-dl & ffmpeg in your PATH. Credit goes to langerhans#2409
package audio;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sx.blah.discord.api.EventSubscriber;
import sx.blah.discord.handle.AudioChannel;
import sx.blah.discord.handle.impl.events.AudioUnqueuedEvent;
import sx.blah.discord.handle.impl.events.MessageReceivedEvent;
import sx.blah.discord.handle.obj.IChannel;
import sx.blah.discord.handle.obj.IMessage;
@quanticc
quanticc / SuperListener.java
Last active April 22, 2016 21:40
Discord4J adapter-like class for all events
package example;
import sx.blah.discord.api.EventSubscriber;
import sx.blah.discord.handle.impl.events.*;
public class SuperListener {
@EventSubscriber public void onAudioPlayEvent(AudioPlayEvent event) {}
@EventSubscriber public void onAudioQueuedEvent(AudioQueuedEvent event) {}
@EventSubscriber public void onAudioReceiveEvent(AudioReceiveEvent event) {}