Skip to content

Instantly share code, notes, and snippets.

View Diapolo10's full-sized avatar
🏠
Working from home

Lari Liuhamo Diapolo10

🏠
Working from home
View GitHub Profile
@Diapolo10
Diapolo10 / main.py
Last active September 7, 2020 16:56
Python print-function mock-up
import sys
from typing import TextIO
def my_print(*args: list, file: TextIO=sys.stdout, sep: str=' ', end: str='\n', flush: bool=False) -> None:
"""
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
@Diapolo10
Diapolo10 / four_fours.py
Last active January 19, 2020 13:51
A general solution for the four fours problem
# log(log(sqrt(4), 4), (sqrt(4)/4)) == 1
import math
def repeat(func, n):
x = 4
for _ in range(n):
x = func(x)
return x
@Diapolo10
Diapolo10 / main.py
Last active February 19, 2023 17:00
Clan Quest OSRS Hiscores
#!python3
from datetime import datetime as dt
import requests
def get_stats(player_name):
player_name = player_name.replace(" ", "_").replace("-", "_")
player_type = 'Normal'
@Diapolo10
Diapolo10 / main.py
Last active August 30, 2019 07:55
Python range-function example definition
#!/usr/bin/env python3
from typing import Generator, Optional
from numbers import Real
def my_range(start: Real, stop: Optional[Real]=None, step: Real=1) -> Generator[Real, None, None]:
""" An example definition of Python 3's range-class as a function """
# If only one argument was provided, use that
# argument as the goal and set start to 0
@echo off
rem Define a (local) name for the temporary file
setlocal
set temp="tmp.txt"
rem Copy the list of outdated modules to a text file
call pip list --outdated > %temp%
rem Process the text file to only contain module names
#!python3
import requests
from urllib.parse import quote
from prettytable import PrettyTable
def measure(user, MAX_XP, MAX_LVL, MAX_ELITE_XP):
SKILL_NAMES = ["Total level", "Attack", "Defence", "Strength", "Constitution",
"Ranged", "Prayer", "Magic", "Cooking", "Woodcutting", "Fletching",
"Fishing", "Firemaking", "Crafting", "Smithing", "Mining",
"Herblore", "Agility", "Thieving", "Slayer", "Farming",
@Diapolo10
Diapolo10 / menu_launcher.py
Created May 22, 2016 19:15 — forked from abishur/menu_launcher.py
A simple menu system using python for the Terminal (Framebufer)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Topmenu and the submenus are based of the example found at this location http://blog.skeltonnetworks.com/2010/03/python-curses-custom-menu/
# The rest of the work was done by Matthew Bennett and he requests you keep these two mentions when you reuse the code :-)
# Basic code refactoring by Andrew Scheller
from time import sleep
import curses, os #curses is the interface for capturing key presses on the menu, os launches the files
screen = curses.initscr() #initializes a new window for capturing key presses
curses.noecho() # Disables automatic echoing of key presses (prevents program from input each key twice)