Skip to content

Instantly share code, notes, and snippets.

@kjd
kjd / psl_missing_tlds.py
Last active August 30, 2022 23:27
Which TLDs are not in the Public Suffix List?
#!/usr/bin/env python3
import requests, idna
PUBLIC_SUFFIX_URL = 'https://publicsuffix.org/list/public_suffix_list.dat'
DELEGATED_TLDS_URL = 'https://data.iana.org/TLD/tlds-alpha-by-domain.txt'
current_suffixes = [x for x in requests.get(PUBLIC_SUFFIX_URL).text.split('\n') if x and not x.startswith('//')]
current_tlds = [idna.decode(x) for x in requests.get(DELEGATED_TLDS_URL).text.split('\n') if x and not x.startswith('#')]
@kjd
kjd / cctld_flags.py
Created June 16, 2017 16:49
ccTLD to flags with Emoji
def cctld_to_flag(domain):
for letter in domain:
print(chr(ord(letter)+127365), end='')
cctld_to_flag('au')
### Keybase proof
I hereby claim:
* I am kjd on github.
* I am kjd (https://keybase.io/kjd) on keybase.
* I have a public key whose fingerprint is E6D9 BAAD 8BE6 9E14 F383 7E49 D9B1 54C1 4A6C 23DC
To claim this, I am signing this object:
#!/usr/bin/env python
#
# Base 58 function used by Flickr e.g. photo id 2360374815 becomes flic.kr/p/4Azxcv
def base58(i):
chars = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
o = ''
while (1):