Skip to content

Instantly share code, notes, and snippets.

>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'en_US')
'en_US'
>>> = locale.format("%d", 123456789, grouping=True)
123,456,789
>>> locale.setlocale(locale.LC_ALL, 'sk_SK')
'sk_SK'
>>> locale.format("%d", 123456789, grouping=True)
123 456 789

Keybase proof

I hereby claim:

  • I am ehmo on github.
  • I am turek (https://keybase.io/turek) on keybase.
  • I have a public key whose fingerprint is 97D9 5F5C 45AF 0D22 AF72 8CA8 6D15 F112 A4FE 9431

To claim this, I am signing this object:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import random
import time
n = 10000000
t0 = time.time()
l = range(n)
@ehmo
ehmo / gist:1349819
Created November 9, 2011 00:10
Request a new IP address from TOR in Python
def NewTorIP():
s = socket.socket()
s.connect(('localhost', 9051))
s.send("AUTHENTICATE\r\n")
r = s.recv(1024)
if r.startswith('250'):
s.send("signal NEWNYM\r\n")
r = s.recv(1024)
if r.startswith('250'):
return True