Skip to content

Instantly share code, notes, and snippets.

View Poolitzer's full-sized avatar

Poolitzer

View GitHub Profile
@Poolitzer
Poolitzer / cheating.js
Last active February 17, 2024 16:43
A half-an-hour excuse not to learn javascript code to auto craft new elements at https://neal.fun/infinite-craft/
const pairs = []
async function cheating() {
let elements = document.getElementsByClassName("mobile-items")[0]
let amount = elements.children.length
for (let sender = 0; sender < amount; sender++){
for (let receiver = 0; receiver < amount; receiver++){
if (pairs.includes(sender.toString() + receiver.toString()) || pairs.includes(receiver.toString() + sender.toString())){
continue;
}
@Poolitzer
Poolitzer / bot.py
Created October 21, 2019 18:03
An example of how to download bigger files via telethon, coming from ptb
import asyncio
from telegram.ext import Updater, MessageHandler, Filters
from telethon.utils import resolve_bot_file_id, get_input_location
from telethon import TelegramClient
import logging
logging.basicConfig()
@Poolitzer
Poolitzer / bot.py
Last active September 8, 2022 18:01
Running an IO task with PTB > 20 while the updates are still handled.
# this example is based on https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.loop.run_in_executor
import asyncio
import time
from telegram import Update
from telegram.ext import Application, CommandHandler, ContextTypes, MessageHandler, filters
def blocking_io():
# File operations (such as logging) can block the
var Layout = require("Layout");
var clockLayout = new Layout( {
type:"txt", font:"15%", label:"Hello World", id:"clock",
});
const utils = {
random_element: function(array) {
return array[Math.floor(Math.random() * array.length)];}
};
@Poolitzer
Poolitzer / validation.c
Created October 21, 2021 07:23
scanf_s with validation
// this while loop is active as long as the user didn't input anything or
// their input is out of range
while (validation == 0) {
validation = scanf_s("%d", &day);
// this if is true when either the input is wrong (no number given)
// or when the number is too low/high
if (validation != 1 || day < 1 || day > 31) {
// if validation is 0, the input buffer exists, so I DESTROY it
while ((c = getchar()) != '\n' && c != EOF);
printf("\nSorry, this was the wrong input. You need to give an \
@Poolitzer
Poolitzer / main.py
Created March 23, 2021 12:06
This is a callbackquery paginator
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, Update
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, CallbackContext
def navigation_buttons_generator(index: str):
navigation_buttons = [[InlineKeyboardButton("⏪", callback_data="minus_" + index),
InlineKeyboardButton("⏩", callback_data="plus_" + index)]]
return InlineKeyboardMarkup(navigation_buttons)
@Poolitzer
Poolitzer / bot.py
Created December 8, 2019 08:13
no
import logging
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Updater, CommandHandler, CallbackQueryHandler
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO)
def start_command(update, context):
@Poolitzer
Poolitzer / bot.py
Created January 31, 2020 05:53
Ever wanted to download something and send it via telegram without having to save it to a file? Fear not!
import io
def downloader(bot, url, timeout=None):
# if you receive a timeout error, pass an increasing timeout until you don't
buf = bot.request.retrieve(url, timeout=timeout)
# turning the byte stream into a file_like object without actually writing it to a file
file_like = io.BytesIO(buf)
# and returning it
return file_like
@Poolitzer
Poolitzer / gist:db886b1028b7d7a6654df39f03af55cb
Created February 6, 2019 16:04
This is an example Instantview for the presse-eifel.de website
~version: "2.0"
# this IV is a pretty basic example for a pretty basic website. LET'S GO
?exists: //meta[@content="article"]
# very easy way to determine if our IV should be generated or not. Works well.
body: //article
title: $body//h1[1]
channel: "@PresseEifel"
# basic variables, its their official channel, so we set it as well.
author: //a[@rel="author"]
author_url: //a[@class="url fn n"]/@href