Skip to content

Instantly share code, notes, and snippets.

View GRAYgoose124's full-sized avatar
🦎
Now descending, please wait...

grayson GRAYgoose124

🦎
Now descending, please wait...
View GitHub Profile
// peers.rs
use std::io::prelude::*;
use std::net::{TcpListener, TcpStream};
use itertools::Itertools;
pub struct Peer {
pub buffer: [u8; 256],
server: TcpListener,
clients: Vec<TcpStream>,
}
package GenericIA3D;
import processing.core.PApplet;
import java.util.List;
import java.util.ArrayList;
import java.util.function.Function;
import culebra.viz.*;
@GRAYgoose124
GRAYgoose124 / tslib.lua
Created April 21, 2020 17:09
skeleton touch screen buttons library
-- Library helpers
function get_screen ()
local sides = { "top", "bottom", "left", "right", "front", "back" }
for i = 1, #sides do
if peripheral.isPresent(sides[i]) then
if peripheral.getType(sides[i]) == "monitor" then
local w, h = peripheral.call(sides[i], "getSize")
local win = window.create(peripheral.wrap(sides[i]), 1, 1, w, h)
win.setBackgroundColor(colors.black)
@GRAYgoose124
GRAYgoose124 / reactor_control.lua
Last active April 15, 2020 10:04
reactor control for minecraft extreme reactors, just basic power cycling rn
local function energy_percent()
reactor_energy = peripheral.call("back", "getEnergyStats")
reserve_percent = reactor_energy["energyStored"] / reactor_energy["energyCapacity"]
return reserve_percent
end
local function reactor_loop ()
print("Starting reactor control loop")
active = false
@GRAYgoose124
GRAYgoose124 / base_discord_bot.py
Created March 3, 2020 17:11
basic discord bot
from html.parser import HTMLParser
from discord.ext import commands
# docs on htmlparsing : https://www.pythoncentral.io/html-parser/
# search more if need be, it's the complex part
# docs on discord.py https://discordpy.readthedocs.io
# you really don't need to mess with this at all unless you decide to make it fancier
class MyBot(commands.Bot):
import json
import os
import time
from discord.ext import commands
# Configuration setup
config_path = os.path.join(os.getcwd(), 'resources', 'config.json')
if os.path.exists(config_path):
with open(config_path) as f:
@GRAYgoose124
GRAYgoose124 / plugin.py
Last active May 14, 2018 22:36
Plugins
import logging
import os
from importlib.util import spec_from_file_location, module_from_spec
logger = logging.getLogger(__name__)
class Plugin:
"""The command dictionaries are indexed by the command name and point to a function
which returns a response to send or None if no response is necessary.
>>> a = "my string"
>>> b = "my string"
>>> id(a)
7570480
>>> id(b)
7574128
>>> id("my string")
7574192
>>> id("my string")
7574192
import tkinter as tk
import math
class App(tk.Frame):
def __init__(self, bx, by, bsize, master=None):
super().__init__(master)
self.buttons = []
# This is just a working example of One Time Pads
# NOT FOR SECURE USAGE
import random
from string import printable
rng = random.SystemRandom()
def createkey(length, dictionary=printable):
key = []