Skip to content

Instantly share code, notes, and snippets.

@elazarl
elazarl / SparkEventSource.java
Last active June 17, 2021 08:12
Suuport SSE/Server-Sent-Events/EventSource for java spark sparkjava.com
package com.spark;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.HandlerList;
import org.eclipse.jetty.servlet.*;
import org.eclipse.jetty.servlets.EventSource;
import org.eclipse.jetty.servlets.EventSourceServlet;
import spark.Service;
import spark.Spark;
import spark.embeddedserver.jetty.EmbeddedJettyServer;
@justincjahn
justincjahn / README.md
Last active January 16, 2024 20:15
Minecraft server(s) using systemd and screen.

Install

# Install dependencies
sudo yum install -y java-1.8.0-openjdk screen

# Create a new unprivileged user for minecraft
useradd -r -m -d /opt/minecraft minecraft

# Create the directory that will house our minecraft instances

sudo su --shell /bin/bash minecraft

@ewized
ewized / statusping.py
Last active January 26, 2024 02:18
Python3 class to ping a Minecraft server and get its response including ping in ms
#!/usr/bin/python3
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors
# of this software dedicate any and all copyright interest in the
@insin
insin / cancellable.js
Last active June 22, 2018 16:55
Cancellable callback wrapper
/**
* Returns a function with a .cancel() function which can be used to prevent the
* given function from being called.
*
* Use case: triggering an asyncronous function with new data while an existing
* function for the same task but with old data is still pending a callback, so
* the callback only gets called for the last one to run.
*/
function cancellable(func) {
var cancelled = false