Skip to content

Instantly share code, notes, and snippets.

View hearot's full-sized avatar
👓
Tryin' to C beyond the lights.

hearot hearot

👓
Tryin' to C beyond the lights.
View GitHub Profile
@hearot
hearot / template.cpp
Last active July 31, 2020 18:21
A simple C++ template for competitive programming.
#include <bits/stdc++.h>
using namespace std;
#define INF (ll)1e18
#define ll long long
#define nl "\n"
int main() {
#if !ONLINE_JUDGE && !EVAL
@hearot
hearot / loading_screen.py
Last active June 23, 2020 16:29
Generate a loading screen for a script using only a console
import asyncio
import logging
import os
from itertools import cycle
LOADING_MESSAGES_WAITING = 0.4
OLD_LEN = 0
def edit(message):
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from distutils.dir_util import copy_tree
from shutil import rmtree
from git import Repo
CACHE_DIRECTORY = "../.website"
COMMIT_MESSAGE = "feat: update source to %s"
@hearot
hearot / pendulum_motion.py
Last active August 22, 2022 09:23
A simple generator for the plots of the pendulum motion.
#!/usr/bin/python
# -*- coding: utf-8 -*-
from matplotlib.animation import FuncAnimation
import matplotlib.pyplot as plt
import numpy as np
A, T = np.pi/20, 1.90345
frames = 150
@hearot
hearot / botogram_example.py
Last active August 10, 2019 09:55
botogram_example.py
import botogram
import random
bot = botogram.create("API-KEY")
@bot.command("random")
def random_command(chat, minimum: int = 0, maximum: int = 100):
"""Get a random number between <code>minimum</code> and <code>maximum</code>."""
try:
@hearot
hearot / tictactoe.py
Last active August 24, 2019 16:43
TicTacToe in Python
import itertools
from dataclasses import dataclass
from typing import Callable, List, Optional, Tuple
sign_table = {
0: '/',
1: 'X',
2: 'O'
}
@hearot
hearot / angles.py
Last active January 25, 2019 22:00
Angle operations with Python
import operator
from dataclasses import dataclass
def _set_method(obj: object, name: str, operation: callable):
setattr(obj, name, lambda self, other: Angle.from_float(operation(float(self), float(other))))
_operation_operators = {
'__add__': operator.add,
'__floordiv__': operator.floordiv,
'__mul__': operator.mul,