Skip to content

Instantly share code, notes, and snippets.

View ioistired's full-sized avatar

io ioistired

View GitHub Profile
@cutiful
cutiful / mastodon-ip.md
Last active March 21, 2024 04:00
Detecting the real IP of a Cloudflare'd Mastodon instance

Detecting the real IP of a Cloudflare'd Mastodon instance

NB: This will not work for instances that proxy outgoing requests!

Reading the docs

I wanted to find a way to detect the real IP address of a Mastodon/Pleroma/Misskey/etc instance hosted behind Cloudflare. How to do that? Well, it's federated, which means I can probably get it to send a request to a server of mine! And how to do that? I tried reading the ActivityPub spec. The following caught my attention:

Servers should not trust client submitted content, and federated servers also should not trust content received from a server other than the content's origin without some form of verification.

@Tomboyo
Tomboyo / list_macro.ex
Last active December 7, 2020 07:23
Tersely create long pattern-match expressions for Elixir lists
defmodule ListMacro do
defmacro list(opts) do
free_variable = quote do ; _ end
quote do
unquote(Enum.flat_map(opts, fn
x when is_integer(x) -> List.duplicate(free_variable, x)
x -> [ x ]
end))
end
@132ikl
132ikl / README.md
Last active July 28, 2022 09:54
Weenie Hut General Messaging Protocol

What is Weenie Hut General Messaging Protocol (WHGMP)?

WHGMP is a message protocol which uses 2 Discord bots and 9 channels.

(pssst... click here to see a more detailed project, with the main bot in addition to the messaging protocol)

How does it work?

WHGMP uses the read/unread badge* in a channel to represent a bit (unread = 1, read = 0). By using 8 channels, one byte can be stored.

The sender waits for a message from the user, then begins to send messages to the data channels. After storing a single byte, a message is sent to the "clock" channel, letting the receiver know to check the read/unread status. Based off of that, a single byte is constructed. When a null-byte is received, the resulting string is printed.

@xSke
xSke / acnh_info.py
Created April 10, 2020 20:50
Script for obtaining AC:NH island/profile info by Nintendo account login
import base64
import datetime
import hashlib
import json
import random
import re
import requests
import secrets
import string
import sys
@Treeki
Treeki / TurnipPrices.cpp
Last active November 1, 2024 14:15
AC:NH turnip price calculator
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
// munged from https://github.com/simontime/Resead
namespace sead
{
class Random
{
@smurfix
smurfix / result_taskgroup.py
Last active January 9, 2024 09:31
anyio ResultGatheringTaskgroup
import anyio
from contextlib import asynccontextmanager
class NotYet(RuntimeError):
pass
class ResultGatheringTaskgroup:
def __init__(self):
self.result = []
@EJH2
EJH2 / emoji_map.json
Created November 22, 2019 04:16
discord emoji mapping. This is a JSON file! Please load it with json. Attempting to copy-paste it directly into python will not work!
{
"grinning": "\ud83d\ude00",
"smiley": "\ud83d\ude03",
"smile": "\ud83d\ude04",
"grin": "\ud83d\ude01",
"laughing": "\ud83d\ude06",
"satisfied": "\ud83d\ude06",
"sweat_smile": "\ud83d\ude05",
"joy": "\ud83d\ude02",
"rofl": "\ud83e\udd23",
import timeit as _timeit, math, sys
def _format_time(timespan, precision=3):
if timespan >= 60.0:
parts = [('d', 60*60*24),('h', 60*60),('min', 60), ('s', 1)]
time = []
leftover = timespan
for suffix, length in parts:
value = int(leftover / length)
if value > 0:
@Rapptz
Rapptz / discord_qol.md
Last active October 28, 2022 14:40
For Jake

I restricted these to client-only QoL features that I thought were small.

  • Reverse sorting search
  • Group by Guild in Emoji panel so you can see what guild an emoji is in
  • Disabling "GIF" or "Gift" buttons in the message box
  • Hover over for complete timestamp on messages
    • Maybe the same for embed timestamps?
  • More time information in call messages (e.g. how long it lasted for) (I know it's provided in the message since I have it in d.py)
  • Lock channels so you don't accidentally move them by dragging (this one might be less trivial iunno)
  • Character count indicator for knowing if you're reaching 2000 characters. too hard apparently
@crrapi
crrapi / webserver_and_bot.py
Last active December 7, 2023 16:47
(Don't use if you can) Run a Flask app and a discord.py bot in one program using threads.
# Note: You really should not use this.
# You can easily convert your app
# to use Quart by using async+await
# and then use loop.create_task(bot.start(...))
# before using app.run.
from threading import Thread
from flask import Flask
from functools import partial
from discord.ext import commands