Skip to content

Instantly share code, notes, and snippets.

@mnordhoff
Created August 9, 2017 08:19
Show Gist options
  • Save mnordhoff/9861887c06015ec7df39f4b6451f9c60 to your computer and use it in GitHub Desktop.
Save mnordhoff/9861887c06015ec7df39f4b6451f9c60 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
import idna
def main():
for line in sys.stdin:
line = line.rstrip()
if not line:
continue
if line.startswith(('!', '//')):
continue
if line.startswith('*.'):
line = line[len('*.'):]
print idna.encode(line.decode('utf-8'))
if __name__ == '__main__':
main()
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
def _key(line):
split = line.split('.')
split.reverse()
return split
def main():
sys.stdout.writelines(sorted(set(sys.stdin), key=_key))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment