Skip to content

Instantly share code, notes, and snippets.

View mdashlw's full-sized avatar
🎯
Focusing

mdashlw

🎯
Focusing
View GitHub Profile
@mdashlw
mdashlw / derpibooru-firehose.js
Created March 11, 2024 05:12
Connect to Derpibooru.org firehose socket using Node.js
import { Socket } from "phoenix";
import { WebSocket } from "undici";
const socket = new Socket("wss://derpibooru.org/socket", {
transport: WebSocket,
debug: true,
sessionStorage: {},
});
const firehose = socket.channel("firehose");
@mdashlw
mdashlw / probe-image-size-undici.ts
Created September 15, 2023 09:43
`probe-image-size` with `undici`
async function fastProbe(url: string): Promise<probe.ProbeResult> {
const ac = new AbortController();
const response = await undici.request(url, {
signal: ac.signal,
reset: true,
throwOnError: true,
});
return await probe(response.body).finally(() => {
ac.abort();
@mdashlw
mdashlw / eval.js
Last active August 7, 2023 14:02
Node.js async eval that accepts a context object with code and returns `util.inspect` of the result or the stringified error, along with stdout and stderr - acts exactly like Node.js REPL
const events = require("node:events");
const stream = require("node:stream");
const repl = require("node:repl");
/**
* @param {object} contextObject
* @param {string} code
* @returns {Promise<string>}
*/
async function executeAsyncCode(contextObject, code) {
@mdashlw
mdashlw / hypixel-rsw-rating-calculator.js
Created March 16, 2023 08:28
Hypixel Ranked SkyWars rating calculator. Same algorithm as used by Wrench; 100% accurate.
const args = process.argv.slice(2);
const oldRating = parseInt(args[0]);
const newRating = parseInt(args[1]);
var rating = oldRating;
var wins = 0;
while (rating < newRating) {
if (rating <= 450) {
@mdashlw
mdashlw / hypixel-punishments.json
Last active March 16, 2023 08:20
Hypixel punishments, from a long time ago.
{
"subTypes": {
"MUTE": {
"NEGATIVE_REFERENCE": {
"reason": "Discussing important people or world events in a negative way.",
"shortName": "NR",
"weight": 4
},
"USER_DISRESPECT": {
"reason": "Acting in a manner that is disrespectful to members within the community.",
@mdashlw
mdashlw / hypixel-games.json
Created March 16, 2023 08:15
Hypixel games, as used by hypixel.net a long time ago.
{
"bedwars": {
"id": 58,
"key": "BedWars",
"slug": "bedwars",
"gameType": "BEDWARS",
"name": "BedWars",
"achievementName": "bedwars",
"parkour": "Bedwars",
"statsPrefix": "Bedwars",
@mdashlw
mdashlw / forge.java
Created June 1, 2021 09:02
water smooth lighting
@Mixin(value = BlockInfo.class, remap = false)
public class MixinBlockInfo {
@Redirect(
method = "updateLightMatrix",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/block/Block;isTranslucent()Z",
opcode = Opcodes.INVOKEVIRTUAL
)
// sending keep alive
if (this.networkTickCount - this.lastSentPingPacket > 40L)
{
this.lastSentPingPacket = (long)this.networkTickCount;
this.lastPingTime = this.currentTimeMillis();
this.field_147378_h = (int)this.lastPingTime;
this.sendPacket(new S00PacketKeepAlive(this.field_147378_h));
}
// processing keep alive

Keybase proof

I hereby claim:

  • I am mdashlw on github.
  • I am mdashlw (https://keybase.io/mdashlw) on keybase.
  • I have a public key whose fingerprint is 66D9 5E56 5258 ED64 8C1C 7BBC 0887 AF18 569D ED32

To claim this, I am signing this object:

@mdashlw
mdashlw / AudioBridge.java
Created December 24, 2018 08:40 — forked from DV8FromTheWorld/AudioBridge
Simple Audio bridge written with JDA's new audio receiving system.
/*
* Copyright 2016 Austin Keener
*
* 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
*
* Unless required by applicable law or agreed to in writing, software