Skip to content

Instantly share code, notes, and snippets.

@kjd
kjd / psl_missing_tlds.py
Last active Jun 11, 2018
Which TLDs are not in the Public Suffix List?
View psl_missing_tlds.py
#!/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 Jun 16, 2017
ccTLD to flags with Emoji
View cctld_flags.py
def cctld_to_flag(domain):
for letter in domain:
print(chr(ord(letter)+127365), end='')
cctld_to_flag('au')
View gist:0b94d8cc3c36a4dd54cd
### 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:
View gist:137507
#!/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):