Skip to content

Instantly share code, notes, and snippets.

View iProdigy's full-sized avatar

iProdigy

  • chillin
View GitHub Profile
private static final double INV_SQRT_TWO = 1 / Math.sqrt(2.0);
public static double cdf(double mu, double sigma, double z) {
return cdf((z - mu) / sigma);
}
public static double cdf(double z) {
if (z < -6 || z > 6) return 0;
return 0.5 * (1 + erf(Math.abs(z) * INV_SQRT_TWO) * (z > 0 ? 1 : -1));
}
import com.github.twitch4j.helix.TwitchHelixBuilder
import com.github.twitch4j.helix.domain.Clip
import com.github.twitch4j.util.PaginationUtil
import org.apache.commons.lang.StringEscapeUtils
import java.nio.file.Files
import java.nio.file.Paths
import java.time.Instant
import java.time.temporal.ChronoUnit
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.Executors
final String clientId = "***", clientSecret = "***", redirectUrl = null;
final TwitchIdentityProvider tip = new TwitchIdentityProvider(clientId, clientSecret, redirectUrl);
Supplier<OAuth2Credential> readCredentialFromFile = () -> {
final String initialAccessToken = "***", initialRefreshToken = "***"; // TODO: must be read from file
final OAuth2Credential cred = new OAuth2Credential("twitch", initialAccessToken);
cred.setRefreshToken(initialRefreshToken);
return cred;
};
package com.github.twitch4j;
import com.github.philippheuer.credentialmanager.domain.OAuth2Credential;
import com.github.twitch4j.auth.providers.TwitchIdentityProvider;
import com.github.twitch4j.common.util.ThreadUtils;
import java.util.Collections;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import com.github.philippheuer.events4j.core.EventManager;
import com.github.philippheuer.events4j.simple.SimpleEventHandler;
import com.github.twitch4j.common.util.EventManagerUtils;
import com.github.twitch4j.common.util.TypeConvert;
import com.github.twitch4j.eventsub.EventSubNotification;
import com.github.twitch4j.eventsub.EventSubSubscriptionStatus;
import com.github.twitch4j.eventsub.EventSubTransport;
import com.github.twitch4j.eventsub.EventSubTransportMethod;
import com.github.twitch4j.eventsub.events.ChannelFollowEvent;
import com.github.twitch4j.eventsub.subscriptions.SubscriptionTypes;
import com.github.twitch4j.chat.TwitchChat;
import com.github.twitch4j.chat.TwitchChatBuilder;
import com.github.twitch4j.chat.events.AbstractChannelEvent;
import com.github.twitch4j.chat.events.channel.GiftSubscriptionsEvent;
import com.github.twitch4j.chat.events.channel.SubscriptionEvent;
import com.github.twitch4j.common.events.domain.EventChannel;
import com.github.twitch4j.common.events.domain.EventUser;
import com.github.twitch4j.common.util.TwitchUtils;
import java.util.Collection;