This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import scipy.stats as stats | |
import math | |
import cairo | |
class TexasRanger: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Test of experimental Tornado feature for a streaming request body handler, see | |
# https://github.com/nephics/tornado/commit/1bd964488926aac9ef6b52170d5bec76b36df8a6 | |
# | |
# | |
# Client sending file to server | |
# | |
import tornado.httpclient as httpclient |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import requests | |
import re | |
def fetch(max_length=12, min_length=6): | |
title = None | |
while not title or min_length < len(title) > max_length: | |
url = "https://en.wikipedia.org/wiki/Special:Random" | |
mashup = requests.get(url).text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
target_list = [{"ip": 1, "ad": 0}, {"ip": 2, "ad": 0}] | |
s2 = {"ip": 2} | |
s3 = {"ip": 3} | |
if s2["ip"] not in [x["ip"] for x in target_list]: | |
print(f"{s2['ip']} is new") | |
if s3["ip"] not in [x["ip"] for x in target_list]: | |
print(f"{s2['ip']} is new") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import signal | |
import time | |
import readchar | |
def handler(signum, frame): | |
msg = "Ctrl-c was pressed. Do you really want to exit? y/n " | |
print(msg, end="", flush=True) | |
res = readchar.readchar() | |
if res == 'y': | |
print("") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
a = [3, 3, 3, 3, 3, 3] | |
b = [6, 5, 2, 2, 2, 2] | |
c = [4, 4, 4, 4, 1, 1] | |
a_wins = 0 | |
b_wins = 0 | |
c_wins = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey, Ed25519PublicKey | |
from cryptography.hazmat.primitives import serialization | |
def unhex(hexed): | |
return b''.fromhex(hexed) | |
def sign(private_key, message): | |
private_bytes = unhex(private_key) | |
private_key_raw = Ed25519PrivateKey.generate().from_private_bytes(private_bytes) | |
signature = private_key_raw.sign(message.encode()).hex() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import aiohttp | |
import asyncio | |
async def test(ip): | |
async with aiohttp.ClientSession() as session: | |
async with session.get(ip) as response: | |
print(f"Running test for: {ip}") | |
html = await response.text() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncio | |
import time | |
async def function1(): | |
await asyncio.sleep(2) | |
print("a") | |
async def function2(): | |
print("b") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tornado.ioloop | |
import tornado.web | |
import threading | |
import time | |
class ReadHandler(tornado.web.RequestHandler): | |
def get(self): | |
self.write("hello world") |