Skip to content

Instantly share code, notes, and snippets.

@huzecong
Created January 29, 2020 21:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save huzecong/e6dcafc1bb9bb264f516cae13ad1dc2d to your computer and use it in GitHub Desktop.
Save huzecong/e6dcafc1bb9bb264f516cae13ad1dc2d to your computer and use it in GitHub Desktop.
A snippet to guess the shoutkey for LTI colloquiums
import itertools
from typing import List, Optional
import requests
def get_url(url_base: str, xs: List[int]) -> str:
return url_base + "".join(chr(x + 97) for x in xs)
def attempt(date: str, speaker_last_name: str) -> Optional[str]:
url_base = f"http://aladdin3.inf.cs.cmu.edu/colcheck/?k={speaker_last_name}_{date}"
for n_letters in range(0, 2 + 1):
for xs in itertools.product(*[range(26) for _ in range(n_letters)]):
url = get_url(url_base, xs)
r = requests.get(url)
if b"img" in r.content:
return url
return None
if __name__ == '__main__':
date = "0124"
speaker_last_name = "starzl"
url = attempt(date, speaker_last_name)
if url is None:
print("Failed")
else:
print(url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment