Skip to content

Instantly share code, notes, and snippets.

View jpatrickdill's full-sized avatar

Patrick Dill jpatrickdill

View GitHub Profile
@jpatrickdill
jpatrickdill / features.py
Last active September 9, 2023 19:17
counts switches and crossovers in railway data from overpass turbo
from dataclasses import dataclass, field
from typing import Any
@dataclass
class Feature:
type: str
id: str
@jpatrickdill
jpatrickdill / alerts.tsx
Last active April 1, 2023 11:40
Alerts overlay for React.
import {v4 as uuidv4} from "uuid";
import React, {createContext, ReactNode, useContext, useEffect, useMemo, useRef, useState} from "react";
import clsx from "clsx";
import {ClipLoader} from "react-spinners";
import {useMap, useSet} from "../utils/hooks";
interface IAlert {
id: string,
content?: ReactNode, // Content to display, can be string or custom children
@jpatrickdill
jpatrickdill / threaddump.py
Last active July 21, 2020 02:40
indexes all images from an instagram thread
from selenium import webdriver
import requests
import figa
from redis import Redis
from pprint import pp
@figa.config
class Config:
default = "config.json"
{
"number": 12,
"string": "Hello, world!",
"fruits": ["apple", "pear"],
"person": {
"name": "Zach",
"age": 20
}
}
local url_query = {arg1="val1", arg2="val2"}
local post_json = {a=1, b=2, this="is json"}
local HttpService = game:GetService("HttpService")
local options = {
Url = ("https://httpbin.org/post?%s=%s&%s=%s"):format("arg1", url_query.arg1, "arg2", url_query.arg2),
Method = "POST",
Headers = {["Content-Type"] = "application/json"},
Body = HttpService:JSONEncode(post_json)
local rgb = Color3.fromRGB
local Color = {
Red = {
[50] = rgb(255, 235, 238);
[100] = rgb(255, 205, 210);
[200] = rgb(239, 154, 154);
[300] = rgb(229, 115, 115);
[400] = rgb(239, 83, 80);
@jpatrickdill
jpatrickdill / httpservice.lua
Created June 27, 2019 19:31
Some HttpService code
local HttpService = game:GetService("HttpService")
local options = {
Url = "https://httpbin.org/post?arg=value",
Method = "POST",
Headers = {["Content-Type"] = "application/json"},
Body = HttpService:JSONEncode( {this="json"} )
}
local r = HttpService:RequestAsync(options)
@jpatrickdill
jpatrickdill / discriminator.js
Created March 20, 2018 03:08
User bot that finds users with same discriminator.
const Discord = require("discord.js");
const client = new Discord.Client();
client.on("ready", () => {
console.log("ready");
});
client.on("message", message => {
if ((message.author === client.user) && (message.content.substring(0, 2) === "%%")) {
@jpatrickdill
jpatrickdill / undeleter.js
Last active October 15, 2022 11:25
Listens for deleted messages on discord and dumps them to a channel.
const Discord = require("discord.js");
const client = new Discord.Client();
const config = require("./config.json"); // config from file
/* example config.json:
{
"token": "abcdefghijklmnopqrstuvwxyz", // user or bot token,
"listenTo": ["167423382697148416", "353615025589714946", "210321071511961600"], // list of channel OR guild id's